Connect to Test Flashcards

(38 cards)

1
Q

What types of integration scenarios should you be prepared for under the ‘Connect to and Consume Azure Services and Third-party Services’ domain?

A

Integration Scenarios:

  • Azure Services: Event Grid, Service Bus, and Event Hubs for messaging
  • API Management: Azure API Management for API exposure
  • Third-party Services: APIs or SDKs for external connections
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you subscribe to an Azure Event Grid topic using .NET to handle events?

A

Event Grid Subscription (.NET):

Use an Azure Function with an Event Grid trigger:

csharp
public static void Run([EventGridTrigger] EventGridEvent eventGridEvent, ILogger log)
{
    log.LogInformation($\"Event received: {eventGridEvent.Data.ToString()}\");
}

Configure subscription via Azure CLI:

bash
az eventgrid event-subscription create \
  --name my-subscription \
  --source-resource-id /subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.EventGrid/topics/<topic-name> \
  --endpoint <function-endpoint>

This subscribes a function to the topic’s events.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you send a message to an Azure Service Bus queue using .NET?

A

Service Bus Queue Message (.NET):

Use the Azure.Messaging.ServiceBus library:

```csharp
using Azure.Messaging.ServiceBus;

var client = new ServiceBusClient("your_connection_string");
var sender = client.CreateSender("your_queue_name");
await sender.SendMessageAsync(new ServiceBusMessage(“Hello, Service Bus!”));
await sender.DisposeAsync();
await client.DisposeAsync();
```

This sends a message to the specified queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you consume events from an Azure Event Hub using .NET?

A

Event Hub Consumer (.NET):

Use the Azure.Messaging.EventHubs library with an Event Processor:

```csharp
using Azure.Messaging.EventHubs;
using Azure.Messaging.EventHubs.Consumer;

var connectionString = "your_event_hub_connection_string";
var eventHubName = "your_event_hub_name";
var consumerGroup = "$Default";
var client = new EventHubConsumerClient(consumerGroup, connectionString, eventHubName);

await foreach (PartitionEvent partitionEvent in client.ReadEventsAsync())
{
Console.WriteLine($"Event: {partitionEvent.Data.Body}");
}
```

This reads events from all partitions in the default consumer group.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can the Azure Cosmos DB Change Feed Processor be used to send changes to Azure Event Hubs?

A

Cosmos DB Change Feed to Event Hubs:

Configure the Change Feed Processor to push changes to an Event Hub:

```csharp
using Azure.Messaging.EventHubs;

CosmosClient client = new CosmosClient("your_endpoint", "your_key");
Container monitoredContainer = client.GetContainer("database_name", "monitored_container_name");
Container leaseContainer = client.GetContainer("database_name", "lease_container_name");

var eventHubProducer = new EventHubProducerClient("event_hub_connection_string", "event_hub_name");

ChangeFeedProcessor processor = monitoredContainer
.GetChangeFeedProcessorBuilder<dynamic>(\"changeFeedToEventHub\", async (changes, token) =>
{
foreach (var change in changes)
{
await eventHubProducer.SendAsync(new EventData(System.Text.Json.JsonSerializer.Serialize(change)));
}
})
.WithInstanceName(\"eventHubInstance\")
.WithLeaseContainer(leaseContainer)
.Build();</dynamic>

await processor.StartAsync();
```

This sends Cosmos DB change feed events to an Event Hub.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you import an API into Azure API Management using the Azure CLI?

A

API Management Import (Azure CLI):

Create an API Management instance and import an OpenAPI spec:

```bash
az apim create \
–name my-apim \
–resource-group myResourceGroup \
–publisher-name MyOrg \
–publisher-email admin@myorg.com \
–sku-name Consumption

az apim api import \
–resource-group myResourceGroup \
–service-name my-apim \
–api-id my-api \
–path /myapi \
–specification-format OpenApi \
–specification-url https://example.com/openapi.json
```

This imports an API from an OpenAPI specification.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you call a third-party REST API from an Azure Function using .NET?

A

Third-party API Call (Azure Function):

Use HttpClient in an HTTP-triggered function:

```csharp
using System.Net.Http;
using Microsoft.Azure.Functions.Worker;

[Function("CallThirdPartyApi")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, \"get\")] HttpRequestData req,
FunctionContext context)
{
var client = new HttpClient();
var response = await client.GetAsync(\"https://api.example.com/data\");
string result = await response.Content.ReadAsStringAsync();
return new OkObjectResult(result);
}
```</IActionResult>

This calls a third-party API and returns the response.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you create an Azure API Management instance using the Azure CLI?

A

API Management Instance Creation:

Use the Azure CLI to create an API Management instance:

bash
az apim create \
  --name myapim \
  --resource-group myResourceGroup \
  --location eastus \
  --publisher-name MyOrg \
  --publisher-email admin@myorg.com \
  --sku-name Consumption

This creates a Consumption-tier instance for low-cost, serverless API management.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the subscription key scopes available in Azure API Management (All APIs, Single API, Product), and how do they differ in terms of access control?

A

API Management Subscription Key Scopes:

  • All APIs: Applies to every API accessible from the gateway, offering broad access
  • Single API: Applies to a single imported API and all its endpoints, limiting access to that API
  • Product: A collection of one or more APIs configured in API Management, with different access rules, usage quotas, and terms of use

Configure via CLI:

bash
az apim subscription create \
  --resource-group myResourceGroup \
  --service-name myapim \
  --name mysubscription \
  --scope \"/products/myproduct\"

This assigns a subscription key to a product scope for controlled access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does Azure API Management secure access to APIs using mechanisms other than subscription keys, such as OAuth 2.0, client certificates, and IP allowlisting?

A

API Management Security Mechanisms:

OAuth 2.0: Use OAuth for delegated access, configure via policies:
```xml

<inbound>
<validate-jwt header-name=\"Authorization\" failed-validation-httpcode=\"401\" failed-validation-error-message=\"Unauthorized\">
<issuer>https://login.microsoftonline.com/your_tenant_id/v2.0</issuer>
<required-claims>
<claim name=\"aud\" match=\"equals\" value=\"your_api_id\"/>
</required-claims>
</validate-jwt>
</inbound>

```

Client Certificates: Validate client certificates in policies for mutual TLS

IP Allowlisting: Restrict access to specific IP ranges via policy:
```xml

<inbound>
<ip-filter action=\"allow\">
<address-range from=\"192.168.1.0\" to=\"192.168.1.255\"/>
</ip-filter>
</inbound>

```

These enhance security beyond subscription keys.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the role of policies in Azure API Management, and how are they applied to modify API behavior?

A

API Management Policies:

Policies allow publishers to change API behavior through configuration:

  • A collection of statements executed sequentially in response to requests or responses
  • Applied in the gateway between the API consumer and managed API
  • Can modify inbound requests and outbound responses

Configure in XML document, divided into sections:
```xml

<policies>
<inbound>
<set-header name=\"x-api-key\" exists-action=\"override\">
<value>mykey</value>
</set-header>
</inbound>
<backend>
<forward-request></forward-request>
</backend>
<outbound>
<set-header name=\"Content-Type\" exists-action=\"override\">
<value>application/json</value>
</set-header>
</outbound>
<on-error>
<return-response>
<set-status code=\"500\" reason=\"Internal Server Error\" />
</return-response>
</on-error>
</policies>

```

If an error occurs, remaining steps are skipped and the on-error section is executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does performance-based routing in Azure Traffic Manager optimize traffic handling for a global application?

A

Azure Traffic Manager Performance-Based Routing:

  • Directs users to the endpoint with the lowest latency for faster responses
  • Monitors endpoint performance to adapt to changing network conditions
  • Enhances scalability by routing traffic to the best-performing regions

It’s ideal for minimizing latency in high-demand global applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which policy should you configure in Azure API Management to cache API responses and improve performance for internal services?

A

Configure cache-response policy because:

  • Caches API responses to reduce backend load and improve response times
  • Allows setting cache duration and conditions for specific endpoints
  • Optimizes performance for frequently accessed, static data

Other policies like rate-limit, set-variable, or validate-jwt don’t enable caching.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How does the cache-response policy in Azure API Management enhance performance for API responses?

A

Cache-Response Policy Benefits:

  • Stores API responses to serve subsequent requests faster from the cache
  • Reduces backend load by minimizing repeated calls for static data
  • Supports configurable cache duration and granular caching strategies

It’s ideal for improving API performance and user experience.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which Azure service should you use to ingest and process IoT data from thousands of devices in real-time, with batch processing and storage for future analysis?

A

Use Azure Event Hub for real-time ingestion and Azure Data Lake for storage because:

  • Event Hub handles high-throughput ingestion from thousands of devices in real-time
  • Data Lake stores large volumes of data for batch processing and future analytics
  • Enables efficient real-time and batch processing workflows

Other options like Service Bus, Cosmos DB, or Logic Apps aren’t optimized for high-throughput ingestion and big data storage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do Azure Event Hub and Azure Data Lake together enable real-time analytics and storage for IoT data from thousands of devices?

A

Azure Event Hub + Azure Data Lake:

  • Event Hub ingests millions of events per second for real-time analytics
  • Data Lake stores large-scale data for batch processing and long-term analysis
  • Integrates with analytics services for efficient data workflows

They’re ideal for real-time IoT data processing and scalable storage.

17
Q

What option should you use to configure Azure Cosmos DB to automatically scale based on demand?

A

Set throughput to automatic scaling based on demand because:

  • Dynamically adjusts RU/s to match workload, ensuring performance
  • Reduces costs by scaling down during low demand
  • Simplifies management with real-time adaptation to traffic

Other options like manual RU/s adjustments or hourly scaling don’t adapt dynamically.

18
Q

How does setting throughput to automatic scaling based on demand optimize performance in Azure Cosmos DB?

A

Automatic Scaling Benefits:

  • Adjusts RU/s in real-time to handle traffic spikes efficiently
  • Minimizes costs by reducing throughput during low demand
  • Eliminates manual scaling for seamless performance management

It’s ideal for applications with unpredictable workloads.

19
Q

Which Azure service should you use to ensure minimal downtime during failover for a scalable application with multi-region deployment on Azure?

A

Use Azure Front Door with global routing and failover capabilities because:

  • Automatically reroutes traffic to healthy regions with minimal downtime
  • Provides global load balancing for low-latency access across regions
  • Enhances reliability with health probes and WAF for security

Other options like Traffic Manager, Load Balancer, or Application Gateway don’t handle cross-region failover as efficiently.

20
Q

How does Azure Front Door with global routing and failover capabilities ensure minimal downtime in a multi-region deployment?

A

Azure Front Door Benefits:

  • Reroutes traffic to the nearest healthy region during failover, minimizing downtime
  • Uses health probes to detect failures and ensure high availability
  • Optimizes performance with global load balancing and edge caching

It’s ideal for disaster recovery and high availability in global apps.

21
Q

Which Azure service should you use to efficiently handle large volumes of data from multiple clients with asynchronous message processing?

A

Use Azure Service Bus queues because:

  • Decouples senders and receivers for asynchronous processing
  • Handles high throughput with scalability for large message volumes
  • Ensures reliability with message durability and advanced features like sessions

Other options like Event Grid, Logic Apps, or Storage Queues aren’t designed for heavy message handling.

22
Q

How do Azure Service Bus queues efficiently handle large volumes of messages from multiple clients with asynchronous processing?

A

Azure Service Bus Queues Benefits:

  • Decouple clients and processors for independent scaling and asynchronous handling
  • Support high throughput with durable, reliable message delivery
  • Offer features like sessions and dead-lettering for complex scenarios

They’re ideal for large-scale, asynchronous messaging in Azure.

23
Q

Which Azure service should you configure to automatically scale in response to traffic spikes without manual intervention?

A

Configure Azure App Service with auto-scaling enabled because:

  • Automatically scales instances based on metrics like CPU or HTTP queue length
  • Requires no manual intervention with predefined scaling rules
  • Supports various app types with flexible scaling configurations

Other options like Azure Functions, Kubernetes, or VMs have limitations or require more management.

24
Q

How does Azure App Service with auto-scaling enabled ensure automatic scaling in response to traffic spikes?

A

Azure App Service Auto-scaling:

  • Scales instances up or down based on metrics like CPU or memory usage
  • Operates without manual intervention using predefined rules
  • Optimizes costs by reducing instances during low traffic periods

It’s ideal for apps needing seamless, automatic scaling in Azure.

25
What Azure service should you use to manage authentication for a multi-tenant SaaS application across different tenants?
**Use Azure Active Directory B2B** because: - Enables **secure guest user access** from other organizations for multi-tenant apps - **Integrates with existing Azure AD identities** for seamless authentication - Provides **robust security** with MFA and conditional access policies Other options like **B2C**, **Managed Identity**, or **app registration** aren't suited for **B2B scenarios**.
26
How does Azure Active Directory B2B ensure secure authentication for a multi-tenant SaaS application?
**Azure Active Directory B2B Benefits**: - Allows **guest users from different tenants** to authenticate using their existing credentials - Enhances security with features like **MFA**, **conditional access**, and **auditing** - **Customizes sign-in experiences** for different tenants with branding options It's ideal for **secure**, **collaborative multi-tenant authentication**.
27
Which Azure service should you use to manage secure authentication and authorization for each tenant in a multi-tenant SaaS application on Azure?
**Use Azure Active Directory B2B** because: - Facilitates **secure collaboration** by allowing guest user access across tenants - Ensures **data isolation** and security for each tenant in a shared app - Supports **enterprise-grade authentication** with Azure AD features Other options like **B2C**, **Managed Identity**, or **app registration** don't fit **B2B multi-tenant** needs.
28
How does Azure Active Directory B2B manage secure authentication and authorization for a multi-tenant SaaS application on Azure?
**Azure Active Directory B2B Management**: - Enables **secure guest user authentication** across different tenant organizations - **Maintains data isolation** while providing access to shared app resources - Leverages **Azure AD security features** like conditional access for tenant-specific policies It's ideal for **secure multi-tenant SaaS** authentication and authorization.
29
How do you authenticate to Azure services from application code without storing credentials?
**Credential-Free Authentication**: Use a **managed identity** (system- or user-assigned) and **DefaultAzureCredential**. It retrieves tokens from the environment and **eliminates secrets**.
30
How do you use a managed identity to read a secret from Azure Key Vault in .NET?
**Key Vault Access with Managed Identity**: Grant **Key Vault access policy** or **RBAC** to the managed identity and use: ```csharp using Azure.Identity; using Azure.Security.KeyVault.Secrets; var client = new SecretClient(new Uri(\"https://.vault.azure.net/\"), new DefaultAzureCredential()); KeyVaultSecret secret = await client.GetSecretAsync(\"MySecret\"); string value = secret.Value; ```
31
When should you choose Event Grid vs Event Hub vs Service Bus?
**Azure Messaging Service Selection**: - **Event Grid**: **Reactive eventing** (lightweight events, fan-out, low latency) - **Event Hub**: **High-throughput telemetry/streaming** (millions of events/sec, partitioned) - **Service Bus**: **Enterprise messaging** (commands, queues, topics, ordering, transactions)
32
How do you implement retry with exponential backoff for transient HTTP failures in .NET?
**Retry with Exponential Backoff (.NET)**: Use **Polly**: ```csharp var policy = Policy.Handle() .OrResult(r => (int)r.StatusCode >= 500) .WaitAndRetryAsync(5, i => TimeSpan.FromSeconds(Math.Pow(2, i))); await policy.ExecuteAsync(() => httpClient.GetAsync(url)); ```
33
How do you publish an event to a custom Event Grid topic using Azure CLI?
**Event Grid Event Publishing (Azure CLI)**: Use **az eventgrid event create**: ```bash az eventgrid event create \ --topic-name mytopic \ --resource-group myrg \ --subject \"/app/items/1\" \ --event-type MyApp.ItemCreated \ --data '{\"id\":1,\"name\":\"Item1\"}' \ --data-version 1.0 ```
34
How do you rewrite a backend URL path in Azure API Management?
**Backend URL Rewrite (API Management)**: Use a **rewrite-uri policy**: ```xml ```
35
How do you call Microsoft Graph API from an Azure Function securely?
**Secure Microsoft Graph API Call**: Assign a **managed identity**, grant **Graph permissions**, then: ```csharp var tokenCred = new DefaultAzureCredential(); var graphClient = new GraphServiceClient(tokenCred, new[]{\"https://graph.microsoft.com/.default\"}); var me = await graphClient.Me.GetAsync(); ```
36
How do you send and receive messages with Service Bus topics and subscriptions in .NET?
**Service Bus Topics and Subscriptions (.NET)**: Create **sender on topic** and **processor on subscription**: ```csharp var client = new ServiceBusClient(conn); await client.CreateSender(\"orders\").SendMessageAsync(new ServiceBusMessage(\"hi\")); var proc = client.CreateProcessor(\"orders\",\"region-eu\"); proc.ProcessMessageAsync += async args => Console.WriteLine(args.Message.Body); await proc.StartProcessingAsync(); ```
37
How do you secure Service Bus access using RBAC instead of connection strings?
**Service Bus RBAC Security**: - Enable **Microsoft Entra auth** - Assign role (e.g., **Azure Service Bus Data Sender/Receiver**) to managed identity - Use **DefaultAzureCredential** in the client constructor
38
How do you use Azure App Configuration for centralized settings in .NET?
**Azure App Configuration (.NET)**: Add package **Azure.Data.AppConfiguration** and: ```csharp var client = new ConfigurationClient(new Uri(\"https://.azconfig.io\"), new DefaultAzureCredential()); ConfigurationSetting s = await client.GetConfigurationSettingAsync(\"App:Theme\"); string theme = s.Value; ```