All practice questions

972 questions

Question 441Question

You are deploying a web application to Azure App Service. The application must retrieve a database connection string stored in Azure Key Vault named keyvault1. You need to configure an application setting named ConnectionString using a Key Vault reference that points to a secret named dbsecret. Which of the following represents the correct format to use as the value of the application setting?

Show answer & explanation

Answer: @Microsoft.KeyVault(SecretUri=https://keyvault1.vault.azure.net/secrets/dbsecret/)

Answer

The correct format is '@Microsoft.KeyVault(SecretUri=https://keyvault1.vault.azure.net/secrets/dbsecret/)'
The correct syntax uses the prefix '@Microsoft.KeyVault' and the parameter 'SecretUri' to specify the full URI of the secret in Azure Key Vault.

Step-by-Step Solution

1
Identify the required prefix for Key Vault references in Azure App Service settings.
The prefix must be '@Microsoft.KeyVault'.
Azure App Service requires this specific prefix to detect and parse the value as a Key Vault reference.
2
Determine the correct parameter name when reference is defined by a secret URI.
The parameter name is 'SecretUri'.
The parser expects 'SecretUri' followed by the URL of the Key Vault secret.
3
Combine the prefix and parameter into the final reference string.
'@Microsoft.KeyVault(SecretUri=https://keyvault1.vault.azure.net/secrets/dbsecret/)'
This matches the official syntax format for referencing a secret by URI.

Key Concept

Key Vault Reference Syntax in Azure App Service
Estimated Time:45s
Question 442Question

You are configuring a Standard test in Azure Application Insights to monitor a public HTTP API endpoint. The endpoint requires a custom HTTP header named `X-Auth-Token` containing a static API key to authenticate requests, and it expects an HTTP POST request. You want to ensure the test runs from multiple geographic locations and alerts you if the endpoint becomes unavailable or returns an error status code.

Which of the following statements correctly describes a configuration capability or limitation when setting up this availability test?

Show answer & explanation

Answer: Standard tests support custom HTTP headers and the POST verb, but you must enter the static API key value directly in the test configuration because Standard tests do not natively support Azure Key Vault references.

Answer

Standard tests support custom HTTP headers and the POST verb, but you must enter the static API key value directly in the test configuration because Standard tests do not natively support Azure Key Vault references.
The correct answer identifies that Standard availability tests natively support configuring custom headers and custom HTTP verbs (like POST) directly in the Azure Portal. However, because they are hosted outside of the application's hosting environment context, they cannot resolve `@Microsoft.KeyVault` references, meaning the auth token secret must be entered as a static value in the test properties.

Step-by-Step Solution

1
Analyze the requirements for the availability monitoring solution (HTTP POST request, custom headers, and external multi-region probing).
Determine that a Standard availability test fits the basic request requirements because it supports single-URL testing with customized HTTP verbs, custom headers, and request bodies.
Choosing the correct out-of-the-box tool prevents writing unnecessary custom infrastructure code.
2
Evaluate the limitations of Standard web tests regarding secret management.
Acknowledge that Application Insights Standard tests do not support resolving Azure Key Vault reference syntax.
This prevents runtime authentication failures caused by transmitting the literal reference string to the API.
3
Select the option that correctly describes the capability to configure custom headers and POST verbs while highlighting the direct value configuration limitation.
Identify that the option stating Standard tests support these configurations but require direct value entry is correct.
This matches official Azure documentation for Application Insights availability tests.

Key Concept

Standard availability tests support advanced HTTP configurations (verbs, headers, payloads) but do not support native integration with Azure Key Vault references or dynamic autoscaling.
Question 443Question

You are developing a C# ASP.NET Core web application that will be hosted on an Azure App Service. The application must securely query data from an Azure SQL Database. You decide to use a user-assigned managed identity to authenticate the App Service to the database to ensure that database credentials are not hardcoded. Which sequence of steps should you perform to provision the identity, associate it with the App Service, and configure the database access permissions?

Drag items to arrange them in the correct order

Show answer & explanation

Answer

The correct order of operations is to first create the user-assigned managed identity, then associate it with the App Service, establish an administrative connection to the SQL Database, create a database user mapped to the external provider identity, and lastly assign the database user to the db_datareader role.
The correct sequence begins with provisioning the user-assigned managed identity so it exists in Microsoft Entra ID. Next, this identity is associated with the App Service resource. To configure permissions, an administrator must log into the target database, create a containment user representing the identity, and finally add that user to the db_datareader role.

Step-by-Step Solution

1
Create the user-assigned managed identity.
A managed identity is registered as a standalone resource in Microsoft Entra ID.
This establishes a security principal that can be associated with resources and granted permissions.
2
Associate the user-assigned managed identity with the App Service.
The App Service is configured to run under the context of the user-assigned managed identity.
The hosting environment requires the identity association to make the identity's credentials available to the application's runtime.
3
Connect to the database using a Microsoft Entra ID admin account.
An administrative database session is initialized.
Creating external database users requires administrator-level access to the database.
4
Run the CREATE USER statement with the EXTERNAL PROVIDER clause.
A containment database user is created inside the SQL database.
This maps the database security principal to the external Microsoft Entra ID identity resource.
5
Add the containment user to the db_datareader database role.
The mapped database user receives read access to the database.
Role membership establishes the actual permissions needed by the application.

Key Concept

Configuring user-assigned managed identities involves registering the identity in the directory, associating it with the computing host, and mapping it to a database principal prior to assigning permissions.
Question 444Question

You are developing a background utility service that runs on an on-premises Windows server. The service must periodically retrieve diagnostic data from a secure custom web API protected by Microsoft Entra ID. You register the utility as an application in your Microsoft Entra ID tenant. The service must authenticate programmatically without user interaction using a certificate. Which two configuration steps should you perform? (Choose two.)

Select all that apply

Show answer & explanation

Answer: Upload the public key portion of the certificate to the application registration in Microsoft Entra ID.; Configure the application to request an access token using the OAuth 2.0 client credentials grant flow.

Answer

Upload the public key portion of the certificate to the application registration in Microsoft Entra ID, and configure the application to request an access token using the OAuth 2.0 client credentials grant flow.
For background services running on-premises, authentication is performed via the OAuth 2.0 client credentials flow. Since a certificate is required for authentication, the public key (.cer) must be uploaded to the Microsoft Entra ID application registration. The client service then signs its client assertion locally using the corresponding private key to request an access token.

Step-by-Step Solution

1
Determine the application type and authentication flow.
Since the service runs on-premises as a background process without user interaction, it cannot use managed identity or delegated permissions. It must authenticate using the client credentials flow with a certificate.
Managed identities require Azure hosting, and user-interactive flows are not suitable for background automation.
2
Configure the credentials on the Microsoft Entra ID application registration.
Upload the public key (.cer) of the certificate to the registered application.
Microsoft Entra ID needs the public key to verify the signature of the token request signed by the client's private key.
3
Implement the token request logic in the client application.
Acquire a token from Microsoft Entra ID using the OAuth 2.0 client credentials flow, passing the client assertion signed with the private key.
This retrieves the access token needed to authenticate calls to the custom web API.

Key Concept

Application registration authentication using certificates and client credentials flow
Question 445Question

You are developing a C# console application using the Azure.Storage.Blobs SDK (v12). The application needs to update a blob named report.pdf. To prevent other processes from modifying the blob during the update, you must acquire a 30-second lease on the blob, upload the new content from a stream named contentStream, and then release the lease.

Which two code segments should you use to perform these operations? (Select two.)

Select all that apply

Show answer & explanation

Answer: BlobLeaseClient leaseClient = blobClient.GetBlobLeaseClient();
var response = await leaseClient.AcquireAsync(TimeSpan.FromSeconds(30));
string leaseId = response.Value.LeaseId;; var options = new BlobUploadOptions
{
Conditions = new BlobRequestConditions { LeaseId = leaseId }
};
await blobClient.UploadAsync(contentStream, options);

Answer

To perform a lease-protected update on a blob, you must first obtain a BlobLeaseClient and call AcquireAsync with a duration between 15 and 60 seconds (such as 30 seconds), then pass the acquired LeaseId in the request Conditions property of the BlobUploadOptions when calling UploadAsync.
To safely modify a leased blob, you must acquire a lease and supply the acquired lease ID in the write request. The step of calling AcquireAsync with a duration of 30 seconds correctly obtains the lease because the duration lies within the required range of 15 to 60 seconds. The step of initializing BlobUploadOptions with BlobRequestConditions containing the LeaseId correctly authorizes the write operation during the upload call.

Step-by-Step Solution

1
Acquire the lease on the blob with a valid duration using BlobLeaseClient.
A lease is successfully acquired and a unique lease ID is returned.
Lease durations must be between 15 and 60 seconds, or -1 for infinite. A duration of 30 seconds is valid.
2
Create BlobUploadOptions and set the LeaseId inside BlobRequestConditions.
The upload request includes the lease ID as a precondition.
Writing to a leased blob requires the lease ID to be passed in the request conditions to authorize the modification.
3
Call the UploadAsync method on the BlobClient passing the content stream and the upload options.
The blob is updated with the new content, and the lease remains active until released or expired.
The Storage Service validates the lease ID and allows the write operation to succeed.

Key Concept

Performing Blob lease operations and using lease request conditions to write to leased blobs.
Question 446Question

You are developing a script to migrate application logs between two Azure Storage accounts. You need to copy all blobs from a source container named `logs-prod` in a storage account named `srcstorage` to a destination container named `logs-archive` in a storage account named `deststorage`.

You decide to use the Azure CLI for this task and generate a Shared Access Signature (SAS) token for the source container. You execute the following command:

bash
az storage blob copy start-batch \
--destination-container logs-archive \
--account-name deststorage \
--account-key <dest-account-key> \
--source-container logs-prod \
--source-account-name srcstorage \
--source-sas "?sv=2025-01-05&sr=c&sp=r&se=2026-08-01T00:00:00Z&sig=..."

The command fails with an authorization error (`AuthorizationPermissionMismatch`) and no blobs are copied.

Which modification to the source SAS token configuration will resolve the error?

Show answer & explanation

Answer: Add the List (l) permission to the source SAS token at the container level.

Answer

Add the List (l) permission to the source SAS token at the container level.
To copy multiple blobs in a batch operation using `az storage blob copy start-batch`, the Azure CLI must first list the source container's contents to identify the source blobs and then read their data. The SAS token provided in the source URI must grant both Read (r) and List (l) permissions at the container level. Since the current SAS token only has `sp=r` (Read), the command fails with an authorization error because it cannot list the blobs.

Step-by-Step Solution

1
Analyze the command and the error message.
The CLI command `az storage blob copy start-batch` is attempting a batch copy from the source container. The error is `AuthorizationPermissionMismatch`.
This error indicates that the SAS token provided for the source container lacks one or more permissions required to complete the operation.
2
Identify the operations performed by `start-batch`.
The command must first list the contents of the source container to identify which blobs to copy, and then read the content of each blob.
Listing requires the List (l) permission, while copying the data out requires the Read (r) permission.
3
Check the current SAS token permissions.
The SAS token query string contains `sp=r` (Read only) but is missing `l` (List).
Because List is missing, the Azure CLI cannot enumerate the source blobs, causing the batch command to fail before copying starts.

Key Concept

Required permissions for batch copying blobs using SAS tokens
Estimated Time:2m 0s
Question 447Question

You need to use the Azure CLI to create a new Azure Key Vault, store a database connection string as a secret, and then retrieve that secret. What is the correct sequence of Azure CLI commands to achieve this?

Drag items to arrange them in the correct order

Show answer & explanation

Answer

The correct sequence is to first create the resource group with `az group create`, then create the Key Vault with `az keyvault create`, next store the secret with `az keyvault secret set`, and finally retrieve the secret with `az keyvault secret show`.
To store and retrieve a secret using the Azure CLI, you must progress from global resource containers to the specific secret value. First, the resource group is created. Next, the Key Vault is provisioned within that resource group. Once the vault exists, the secret is written using the set command, and finally, the secret is retrieved using the show command.

Step-by-Step Solution

1
Create the resource group.
A resource group is provisioned in Azure.
Azure Key Vault requires a resource group to hold the resource.
2
Create the Key Vault.
The Key Vault instance is created inside the resource group.
Secrets must be stored within a specific Key Vault instance.
3
Set the secret.
The secret is successfully written to the Key Vault.
The connection string must be written to Key Vault storage before it can be referenced or read.
4
Show the secret.
The secret's value and metadata are returned.
Retrieving the secret requires querying the specific secret name inside the vault.

Key Concept

Azure Key Vault CLI Secret Management Lifecycle
Question 448Question

You are configuring permissions and consent in Microsoft Entra ID for an enterprise scheduling solution consisting of two applications:

1. SyncDaemon: A background service (daemon) that runs continuously without user interaction to synchronize user profile information from Microsoft Graph.
2. PlannerSPA: A client-side Single Page Application (SPA) that allows authenticated users to access a custom backend Web API named `TaskAPI` to manage their tasks. The backend API is registered with the App ID URI `api://taskapi.contoso.com`.

Which two of the following configuration actions must you perform to implement the correct permissions and consent flows? (Select two.)

Select all that apply

Show answer & explanation

Answer: For SyncDaemon, assign the Microsoft Graph Application permission User.Read.All and perform an admin consent flow.; For PlannerSPA, configure the application to request the scope api://taskapi.contoso.com/Tasks.Manage to obtain an access token for the backend API.

Answer

To configure the solution correctly, assign the Microsoft Graph Application permission User.Read.All with admin consent for SyncDaemon, and configure PlannerSPA to request the fully qualified scope api://taskapi.contoso.com/Tasks.Manage.
The correct actions are assigning the Application permission User.Read.All with admin consent for the background SyncDaemon service, and requesting the fully qualified custom scope api://taskapi.contoso.com/Tasks.Manage for the PlannerSPA. Background daemons run without user interaction and require Application permissions with tenant admin consent. Single-page applications calling a custom API require delegated access using the fully qualified App ID URI scope format.

Step-by-Step Solution

1
Determine the identity flow and permission type for SyncDaemon.
Since SyncDaemon is a background service running without user interaction, it must use the client credentials flow, which requires Application permissions (User.Read.All) rather than Delegated permissions.
Delegated permissions require an active user session, whereas Application permissions represent the application's identity.
2
Determine the consent requirement for SyncDaemon's permissions.
Microsoft Graph Application permissions require tenant-wide admin consent.
Admin consent prevents non-admin users from granting permissions that could access directory-wide data.
3
Determine the correct scope syntax for PlannerSPA calling TaskAPI.
The scope must be fully qualified as api://taskapi.contoso.com/Tasks.Manage.
Microsoft Entra ID requires custom API scopes to be requested using their full URI prefix so it can resolve the target resource registration.

Key Concept

Distinction between Delegated and Application permissions, and proper custom API scope syntax in Microsoft Entra ID.
Question 449Question

You are developing a custom availability monitoring tool as a scheduled console application that runs on an Azure Virtual Machine (VM). The application monitors an internal HTTP service and uses the Azure Application Insights SDK to track availability using the `TrackAvailability()` method.

You write the following C# code to log the test results:

csharp
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;

var configuration = TelemetryConfiguration.CreateDefault();
var telemetryClient = new TelemetryClient(configuration);

var availability = new AvailabilityTelemetry
{
Name = "InternalServiceCheck",
RunLocation = "AzureVM-EastUS",
Success = true
};

telemetryClient.TrackAvailability(availability);
telemetryClient.Flush();

During testing, you notice that availability metrics are not appearing in Application Insights. The connection string for Application Insights is stored in an Azure Key Vault secret.

Which two of the following configuration steps should you perform to resolve this issue and ensure the availability telemetry is securely sent to Application Insights? (Select two)

Select all that apply

Show answer & explanation

Answer: Set the `ConnectionString` property of the `TelemetryConfiguration` object using the connection string value retrieved from Azure Key Vault.; Assign a system-assigned managed identity to the Azure Virtual Machine and grant it the Key Vault Secrets User role on the Key Vault containing the connection string.

Answer

Assign a system-assigned managed identity to the Azure Virtual Machine, grant it the Key Vault Secrets User role on the Key Vault, and set the `ConnectionString` property of the `TelemetryConfiguration` object using the retrieved connection string.
To resolve the missing telemetry issue securely, you must retrieve the connection string from Key Vault and supply it to the Application Insights SDK. This is done by enabling a system-assigned managed identity on the Azure VM and granting it the Key Vault Secrets User role, allowing the application to fetch the secret at runtime. In the code, the retrieved connection string must be assigned to the `ConnectionString` property of the `TelemetryConfiguration` object passed to the `TelemetryClient` constructor.

Step-by-Step Solution

1
Enable system-assigned managed identity on the Azure Virtual Machine hosting the console application.
The VM is assigned a unique identity in Microsoft Entra ID.
This identity allows the VM to authenticate to Azure resources like Key Vault without hardcoded credentials.
2
Grant the VM's managed identity the Key Vault Secrets User role on the Key Vault containing the Application Insights connection string.
The application running on the VM can retrieve the connection string secret using Azure Identity SDK.
By default, managed identities do not have access to Key Vault secrets, so explicit permission must be granted.
3
Retrieve the connection string in the application code and set it on the `TelemetryConfiguration.ConnectionString` property before instantiating the `TelemetryClient`.
The telemetry client is correctly initialized with the connection string.
Application Insights SDK requires the connection string to determine where to send the availability telemetry data.

Key Concept

Custom availability monitoring with the Application Insights SDK requires initializing the TelemetryClient with a valid connection string, which can be securely retrieved from Key Vault using a VM's managed identity.
Question 450Question

You are configuring a custom availability monitoring tool that runs as a continuous background process on an internal server. The tool executes health checks and uses the Azure Application Insights SDK to report results. You use the following class to send telemetry:

csharp
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;

public class HealthReporter
{
private static TelemetryClient telemetryClient = new TelemetryClient();

public static void SendResult(bool success)
{
var availability = new AvailabilityTelemetry
{
Name = "InternalApiTest",
Success = success,
RunLocation = "CorporateNetwork"
};
telemetryClient.TrackAvailability(availability);
}
}

Although the background process runs continuously and calls the `SendResult` method, no availability data appears in the Azure Portal, and no exceptions are logged locally.

Which of the following is the most likely cause of this issue?

Show answer & explanation

Answer: The connection string for the Application Insights resource was not configured, causing the SDK to silently drop the telemetry.

Answer

The connection string for the Application Insights resource was not configured, causing the SDK to silently drop the telemetry.
The correct answer explains that the connection string was not configured. The TelemetryClient requires a destination to route telemetry. When no connection string is set, the SDK drops the data silently to prevent application crashes.

Step-by-Step Solution

1
Analyze the initialization of the TelemetryClient in the code snippet.
The code uses `new TelemetryClient()` without passing an explicit configuration.
This initialization relies on the default TelemetryConfiguration, which must resolve the connection string from environment variables or local configuration files.
2
Evaluate the SDK behavior when the target endpoint/connection string is missing.
Without a valid connection string, the SDK behaves in a loop-back/no-op mode, dropping the telemetry.
This design choice prevents monitoring configuration issues from breaking core application runtime execution.

Key Concept

Application Insights SDK Configuration and Telemetry Ingestion Requirements
Question 451Question

You are deploying an Azure App Service web app that must retrieve a database connection string from an Azure Key Vault using a user-assigned managed identity for compliance reasons. The Key Vault uses Azure Role-Based Access Control (RBAC) for authorization.

The user-assigned managed identity has been assigned the 'Key Vault Secrets User' role on the Key Vault. You use the following Bicep template snippet to deploy the web app:

bicep
resource webApp 'Microsoft.Web/sites@2022-03-01' = {
name: webAppName
location: location
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${userAssignedIdentityId}': {}
}
}
properties: {
siteConfig: {
appSettings: [
{
name: 'ConnectionStrings__Default'
value: '@Microsoft.KeyVault(SecretUri=https://kv-prod-01.vault.azure.net/secrets/DbConn)'
}
]
}
}
}

During deployment validation, the application fails to start, and the logs indicate that the application setting `ConnectionStrings__Default` cannot resolve the Key Vault reference.

Which configuration change must you apply to the Bicep template to ensure the web app can resolve the connection string?

Show answer & explanation

Answer: Set the keyVaultReferenceIdentity property under properties to the value of userAssignedIdentityId.

Answer

Set the keyVaultReferenceIdentity property under properties to the value of userAssignedIdentityId.
The correct solution is to set the keyVaultReferenceIdentity property under properties to the value of the user-assigned managed identity's resource ID. By default, Azure App Service attempts to resolve Key Vault configuration references using the system-assigned managed identity. When using a user-assigned identity instead, the App Service must be explicitly told which identity to use by configuring the keyVaultReferenceIdentity property.

Step-by-Step Solution

1
Analyze the Bicep template configuration
Identify that the Web App is configured with a user-assigned managed identity, but lacks configuration pointing the Key Vault resolution mechanism to this identity.
When a Key Vault reference is evaluated at runtime, the App Service host must authenticate against the Key Vault. By default, it attempts to use a system-assigned identity.
2
Determine the default identity resolution behavior
Realize that without a system-assigned identity enabled or explicit configuration, the App Service cannot authenticate to resolve `@Microsoft.KeyVault(...)` syntax.
The template uses a user-assigned managed identity instead of a system-assigned identity, so the host needs explicit guidance on which identity context to execute under.
3
Identify the required Bicep property for identity selection
Locate the keyVaultReferenceIdentity property under the properties block of Microsoft.Web/sites.
This property configures the specific user-assigned identity resource ID that the App Service host should use to authenticate against the Key Vault for App Setting reference resolution.
4
Validate the Key Vault reference syntax and RBAC configuration
Ensure the @Microsoft.KeyVault(SecretUri=...) syntax is correct and Key Vault Secrets User role is active on the user-assigned identity.
The role and syntax are already correct in the initial template, confirming that the missing keyVaultReferenceIdentity property is the sole blocker.

Key Concept

App Service Key Vault References with User-Assigned Managed Identity

Alternative Method

Alternatively, you could switch to using a system-assigned managed identity, which automatically configures the App Service to use that identity for Key Vault references without needing the keyVaultReferenceIdentity property. However, this may conflict with organizations requiring user-assigned identities for strict lifecycle management.
Estimated Time:3m 0s
Question 452Question

You are authoring a Bicep template to deploy an Azure App Service web app that requires access to a shared Azure Key Vault. The web app must use a user-assigned managed identity named `app-identity` that is defined in the same template.

You declare the user-assigned managed identity resource as follows:

bicep
resource appIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: 'app-identity'
location: location
}

You need to define the `identity` property of the App Service web app resource to assign this managed identity.

Which Bicep block should you include in the App Service resource definition?

Show answer & explanation

Answer: identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${appIdentity.id}': {}
}
}

Answer

The correct Bicep block must set the identity type to 'UserAssigned' and define the userAssignedIdentities property as a dictionary with the managed identity's resource ID as the key and an empty object as the value.
The correct Bicep block sets the type to 'UserAssigned' and maps the resource ID of the identity as a key in the userAssignedIdentities object with an empty object value. In ARM/Bicep, the user-assigned identities are represented as a dictionary/object to allow assigning multiple identities, where each key is the unique resource ID of an identity.

Step-by-Step Solution

1
Analyze the resource definition requirements for assigning a user-assigned managed identity in Bicep/ARM.
The identity property requires setting the type property and specifying the identity resource(s).
This establishes the identity configuration schema used by the Azure Resource Manager.
2
Determine the correct value for the type property.
The type property must be set to 'UserAssigned'.
This tells Azure to associate one or more user-assigned managed identities rather than a system-assigned identity.
3
Specify the user-assigned identity using its resource ID.
Use the userAssignedIdentities property, structured as a dictionary (object) where the keys are the resource IDs (e.g., appIdentity.id) and the values are empty objects.
The ARM API expects a JSON object map to support multiple user-assigned identities, rather than a string array or a single property name.

Key Concept

Configuring user-assigned managed identities in Bicep/ARM templates
Estimated Time:1m 30s
Question 453Question

You are developing a C# console application that retrieves a specific product configuration document from an Azure Cosmos DB container by using the .NET SDK v3. You need to write the code that performs a point read of the item. Which sequence of actions should you perform to complete this operation? To answer, arrange the actions in the correct order.

Drag items to arrange them in the correct order

Show answer & explanation

Answer

To perform a point read, you must first instantiate a CosmosClient. Next, call GetDatabase on the CosmosClient to retrieve the Database reference. Then, call GetContainer on the Database to retrieve the Container reference. After that, initialize a PartitionKey structure with the partition key value. Finally, call ReadItemAsync on the Container, passing the unique identifier and the PartitionKey.
The correct sequence starts with instantiating the CosmosClient, which establishes the connection pool. You then call GetDatabase on the client and GetContainer on the database to navigate the SDK hierarchy. Before executing the read, you instantiate the PartitionKey with the target value. Finally, you execute the point read by calling ReadItemAsync on the container with the item ID and PartitionKey.

Step-by-Step Solution

1
Instantiate the CosmosClient object.
A CosmosClient instance is created, initiating the connection and client-side caching.
The client is the root object required to interact with any Azure Cosmos DB resources.
2
Call GetDatabase on the CosmosClient instance.
A Database object reference is returned.
You must navigate the resource hierarchy from the client down to the database before accessing containers.
3
Call GetContainer on the Database instance.
A Container object reference is returned.
All item-level operations are executed against a container reference.
4
Create a PartitionKey instance with the item's partition key value.
A PartitionKey structure is initialized.
The SDK v3 requires an explicit PartitionKey parameter for point operations to ensure efficient routing.
5
Call ReadItemAsync on the Container instance, passing the ID and PartitionKey.
An ItemResponse is returned, containing the document data.
This executing call performs the actual point read operation over the network.

Key Concept

Executing container and item operations using the Azure Cosmos DB .NET SDK v3 requires initializing the CosmosClient, obtaining Database and Container references, and providing a PartitionKey to the item operation method.
Question 454Question

An Azure App Service web app uses a system-assigned managed identity to load configuration from an Azure App Configuration store. The App Configuration store contains a Key Vault reference that points to a secret stored in Azure Key Vault. While the web app successfully retrieves standard key-value settings, it fails to resolve the Key Vault reference at runtime. Which configuration change is required to allow the web app to resolve the Key Vault reference?

Show answer & explanation

Answer: Grant the system-assigned managed identity of the web app the Secret Get permission on the Key Vault.

Answer

Grant the system-assigned managed identity of the web app the Secret Get permission on the Key Vault.
The correct approach is to grant the system-assigned managed identity of the web app the Secret Get permission on the Key Vault. Key Vault references stored in Azure App Configuration are not resolved by the App Configuration service itself. Instead, the application's configuration provider fetches the reference metadata (the secret URI) from the App Configuration store, and then the application uses its own credentials to fetch the actual secret value directly from the Key Vault. Therefore, the web app's identity must have read access to the Key Vault.

Step-by-Step Solution

1
Identify how Key Vault references in Azure App Configuration are resolved.
References are resolved at runtime by the application client library, not by the Azure App Configuration service.
This determines which service identity requires access to the Key Vault.
2
Determine the identity used by the application to access Azure resources.
The application uses its own system-assigned managed identity.
This is the security principal that must be authorized on the Key Vault.
3
Configure the access control policy on the target Key Vault.
Grant the web app's system-assigned managed identity the 'Secret Get' permission (or the 'Key Vault Secrets User' role).
This enables the web app to directly retrieve the secret payload from the vault when resolving the reference.

Key Concept

Key Vault references in Azure App Configuration are resolved by the client application at runtime, requiring the application's identity to have access permissions on the target Key Vault.
Question 455Question

You are writing a C# console application using the Azure.Storage.Blobs SDK (version 12.x) to migrate archive data from a source Azure Storage account to a destination storage account. The source container is private, and you want to perform the transfer asynchronously while monitoring the process. Arrange the following steps in the correct sequence to copy the blob and determine when the operation finishes.

Drag items to arrange them in the correct order

Show answer & explanation

Answer

Generate the read-only SAS token for the source blob, instantiate the destination BlobContainerClient, obtain the destination BlobClient, initiate the copy using StartCopyFromUriAsync with the source URI, and poll the destination properties until the CopyStatus completes.
To copy a private blob asynchronously between storage accounts, you must first generate a read-only SAS token for the source blob. Next, create a container client and then a blob client for the destination target. With these clients set up, call StartCopyFromUriAsync on the destination blob client to prompt the service to pull data from the source URI. Finally, poll the destination properties using GetPropertiesAsync to monitor the copy status until it resolves.

Step-by-Step Solution

1
Generate a SAS token with read permissions on the source blob.
An authenticated URI pointing to the source blob is acquired.
The destination storage account requires read authorization to fetch the source blob's data.
2
Instantiate a BlobContainerClient for the destination container.
A service client targeting the destination container is created.
You must have a reference to the container before you can address specific blobs inside it.
3
Call GetBlobClient on the container client.
A BlobClient object representing the destination blob is returned.
The copying action is initiated on the target blob client itself.
4
Invoke StartCopyFromUriAsync on the destination BlobClient.
The copy task is queued on the Azure service backend.
This starts the asynchronous copy operation between the storage accounts.
5
Loop to call GetPropertiesAsync on the destination BlobClient.
The copy process completes with success or failure.
Because the copy is executed on the Azure service backend, the client must query the destination blob properties to find out when the status changes from Pending.

Key Concept

Asynchronous Blob Copying using the Azure.Storage.Blobs SDK

Alternative Method

Instead of polling the destination blob properties programmatically, you can listen to Microsoft.Storage.BlobCreated events using Azure Event Grid to handle completion reactively.
Estimated Time:2m 0s
Question 456Question

You are deploying an Azure App Service web application that needs to retrieve a database connection string from an Azure Key Vault named my-keyvault. The connection string is stored as a secret named db-conn-string. You decide to use a Key Vault reference in the App Service application settings to retrieve the secret. Which of the following values represents the correct syntax format to reference this secret?

Show answer & explanation

Answer: @Microsoft.KeyVault(SecretUri=https://my-keyvault.vault.azure.net/secrets/db-conn-string/)

Answer

The correct format is the option that uses the @Microsoft.KeyVault prefix followed by the SecretUri parameter pointing to the secret's URI, specifically: @Microsoft.KeyVault(SecretUri=https://my-keyvault.vault.azure.net/secrets/db-conn-string/).
The correct format uses the prefix '@Microsoft.KeyVault' followed by the 'SecretUri' parameter pointing to the URI of the secret in Azure Key Vault: @Microsoft.KeyVault(SecretUri=https://my-keyvault.vault.azure.net/secrets/db-conn-string/). This allows the App Service to authenticate using its managed identity and retrieve the secret at runtime.

Step-by-Step Solution

1
Identify the service and feature being configured.
Azure App Service Application Settings using a Key Vault reference.
This allows the App Service to automatically resolve the secret from Key Vault without application code changes.
2
Determine the prefix required for Key Vault references.
The prefix must be exactly '@Microsoft.KeyVault'.
Azure App Service parser looks for this specific prefix to resolve Key Vault secrets at runtime.
3
Identify the required parameter format inside the parentheses.
The parameter is 'SecretUri=' followed by the full URI of the secret.
This uniquely identifies the secret vault, secret name, and optionally the version.

Key Concept

Azure Key Vault Reference Syntax in Azure App Service Configuration
Question 457Question

You are developing a Python background utility to safely update a shared configuration file stored in Azure Blob Storage. The application uses the azure-storage-blob SDK (v12).

To prevent concurrent writes, the application first acquires a lease on the blob using the following code:

python
from azure.storage.blob import BlobServiceClient, BlobLeaseClient

connection_string = "UseDevelopmentStorage=true"
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
blob_client = blob_service_client.get_blob_client(container="configs", blob="appsettings.json")

# Acquire a 30-second lease on the blob
lease_client = BlobLeaseClient(blob_client)
lease_client.acquire(lease_duration=30)

# Modify the configuration data
updated_config_data = b'{"status": "ready", "version": "2.0"}'

Which of the following code statements must you use to upload the updated configuration to the leased blob?

Show answer & explanation

Answer: blob_client.upload_blob(updated_config_data, overwrite=True, lease=lease_client)

Answer

blob_client.upload_blob(updated_config_data, overwrite=True, lease=lease_client)
The correct statement is the option using the lease parameter set to the lease_client object. In the Azure Storage SDK for Python (v12), you authorize modifications to a leased blob by passing either the BlobLeaseClient instance or its lease_id string to the lease parameter of the write operation (such as upload_blob).

Step-by-Step Solution

1
Initialize the lease client and acquire the lease
The blob is leased for 30 seconds, preventing other clients from writing or deleting it without providing the lease ID.
Secures the blob for safe updates.
2
Call upload_blob and pass the lease argument
The write operation is sent to Azure Storage with the lease identifier included in the request headers automatically by the SDK.
Allows the write operation to bypass the lease block since the caller owns the lease.

Key Concept

Writing to leased blobs using the Azure Storage Python SDK v12
Question 458Question

An organization is deploying a multi-tenant web application named App1 to Azure App Service. App1 needs to authenticate users from any Microsoft Entra ID tenant but must restrict access to corporate (work or school) accounts only, preventing personal Microsoft accounts from signing in. You are configuring the application registration manifest and the authentication authority endpoint in the application code.

Which of the following configurations should you apply to satisfy these requirements?

Show answer & explanation

Answer: Set the signInAudience parameter to AzureADMultipleOrgs and use the authority endpoint https://login.microsoftonline.com/organizations

Answer

Set the signInAudience parameter to AzureADMultipleOrgs and use the authority endpoint https://login.microsoftonline.com/organizations
The correct configuration is to set the signInAudience to AzureADMultipleOrgs and use the /organizations authority endpoint. This ensures the application accepts authentication requests only from organizational (work or school) directories across any tenant while preventing personal Microsoft accounts from signing in.

Step-by-Step Solution

1
Analyze the tenant requirement
The application must support users from multiple external Microsoft Entra ID tenants, meaning a multi-tenant configuration is required.
Single-tenant configuration (AzureADMyOrg) will restrict logins to a single tenant.
2
Select the correct signInAudience
Choose AzureADMultipleOrgs instead of AzureADandPersonalMicrosoftAccount.
The requirement explicitly states that personal accounts must be blocked. AzureADMultipleOrgs targets only corporate accounts across tenants.
3
Select the correct authority endpoint
Use the /organizations endpoint instead of the /common endpoint.
The /organizations endpoint restricts sign-in requests to organizational accounts only, whereas the /common endpoint accepts both organizational and personal accounts.

Key Concept

Configuring multi-tenant Microsoft Entra ID applications with appropriate sign-in audiences and authorization endpoints.
Estimated Time:2m 0s
Question 459Question

A developer uploads a blob to Azure Blob Storage and configures its metadata using the Azure.Storage.Blobs SDK (v12) for C# with the following code:

csharp
var metadata = new Dictionary<string, string>
{
{ "Department", "Finance" }
};
await blobClient.SetMetadataAsync(metadata);

Later, the developer retrieves the properties of the blob using the following code:

csharp
BlobProperties properties = await blobClient.GetPropertiesAsync();

Which code segment should the developer use to successfully retrieve the metadata value "Finance"?

Show answer & explanation

Answer: string department = properties.Metadata["department"];

Answer

string department = properties.Metadata["department"];
The correct answer uses the lowercase key 'department'. The Azure Storage REST API returns custom metadata as HTTP headers with the 'x-ms-meta-' prefix, converting key names to lowercase. The Azure.Storage.Blobs SDK automatically strips the 'x-ms-meta-' prefix but leaves the keys lowercased. Since the standard .NET Dictionary used for properties.Metadata is case-sensitive, the lookup must match the lowercase format exactly.

Step-by-Step Solution

1
Analyze how custom metadata headers are processed by the Azure Storage service.
The service stores custom metadata as HTTP headers, prepending each key with 'x-ms-meta-' and converting all characters to lowercase.
Understanding the service-side serialization explains the format of the keys returned during retrieval.
2
Analyze how the Azure.Storage.Blobs SDK processes retrieved metadata.
The SDK strips the 'x-ms-meta-' prefix from HTTP headers but preserves the lowercase format returned by the service when constructing the Metadata dictionary.
This determines that the final keys in the dictionary will be in lowercase.
3
Perform dictionary retrieval using the correct key format.
Accessing properties.Metadata["department"] returns the correct value because dictionary key lookup in .NET is case-sensitive, matching the lowercase key.
Selecting the exact key prevents a KeyNotFoundException.

Key Concept

Azure Blob Storage SDK metadata naming casing rules and prefix stripping
Question 460Question

You manage an Azure App Service Web App named RetailCartService that is currently hosted on a Free (F1) App Service plan. You need to implement and test CPU-based autoscaling for the application. You must ensure the application scales out to multiple instances under high load and scales back in when load decreases.

Which of the following represents the correct sequence of steps to configure and verify this autoscale behavior?

Drag items to arrange them in the correct order

Show answer & explanation

Answer

The correct sequence of steps starts with scaling up the App Service plan to the Standard tier, followed by enabling custom autoscale and defining the scaling rules. Next, synthetic load is generated to trigger the scale-out rule, and finally, the instance count is monitored to confirm the scale-out occurred.
The correct sequence begins with upgrading the App Service plan because scaling out and custom autoscale rules are not supported on the Free (F1) tier. Once scaled to the Standard (S1) tier, custom autoscale rules can be configured. To verify the configuration, synthetic load must be generated to trigger the scale-out threshold, and then the instance count is monitored to confirm the scale-out event succeeded.

Step-by-Step Solution

1
Scale up the hosting plan.
The App Service plan is upgraded from the Free (F1) tier to the Standard (S1) tier.
Free and Shared tiers do not support custom autoscale or scale-out capabilities. Standard (S) or Premium (P) tiers are required.
2
Configure the autoscale rules.
Custom autoscale is enabled with CPU-based scale-out and scale-in rules.
This establishes the autoscale profile and thresholds that govern the scale-out and scale-in operations.
3
Trigger the scale-out condition.
CPU utilization on the Web App increases beyond the scale-out threshold.
Synthetic load must be applied to simulate peak traffic and evaluate whether the autoscale engine detects the metric threshold breach.
4
Verify the scale-out outcome.
The App Service plan scales out to additional instances.
Monitoring the instance count confirms that the autoscale engine executed the rule and added capacity successfully.

Key Concept

Autoscaling configuration and verification workflow for Azure App Service Web Apps.
Estimated Time:1m 30s
PreviousPage 23 / 49Next
All practice questions — Microsoft Azure Developer (AZ-204) | Examkin