Implement Azure Security (15-20%) Flashcards

This section addresses authentication, authorization, and securing solutions with Key Vault and Managed Identities. (41 cards)

1
Q

What are the primary security areas you need to master under the “Implement Azure Security” domain?

A

Key topics include:
- Implementing authentication and authorization (e.g., Microsoft Entra ID, OAuth 2.0).
- Securing data with Azure Key Vault for keys, secrets, and certificates.
- Using Managed Identities to eliminate credential management.

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

How can you use the Microsoft Authentication Library (MSAL) in .NET to authenticate an application with Microsoft Entra ID?

A

Use the PublicClientApplicationBuilder to acquire a token:
```csharp
using Microsoft.Identity.Client;

var app = PublicClientApplicationBuilder
.Create(“your_client_id”)
.WithAuthority(“https://login.microsoftonline.com/your_tenant_id”)
.Build();
var scopes = new[] { “User.Read” };
var result = await app.AcquireTokenInteractive(scopes).ExecuteAsync();
string accessToken = result.AccessToken;
```
This authenticates interactively and retrieves an access token for the specified scope.

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

What is the difference between delegated permissions and application permissions when authorizing with Microsoft Entra ID?

A
  • Delegated Permissions: Used when a signed-in user is present; the app acts on behalf of the user (e.g., accessing user data with user consent).
  • Application Permissions: Used for apps running without a user (e.g., daemons); the app acts as itself and requires admin consent (e.g., reading all users in a tenant).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you enable a system-assigned Managed Identity for an Azure App Service using the Azure CLI?

A

Use the az webapp identity assign command:

bash
az webapp identity assign --resource-group <resource-group> --name <app-name>

This enables a system-assigned identity tied to the app’s lifecycle, allowing it to authenticate to Azure resources without managing credentials.

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

What are the primary features of Azure Key Vault that help secure data for applications?

A

Key features include:
- Secrets Management: Securely store tokens, passwords, and API keys.
- Key Management: Create and control encryption keys.
- Certificate Management: Provision, manage, and deploy SSL/TLS certificates.
All are protected with Microsoft Entra ID authentication and role-based access control (RBAC).

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

How can you generate a new version of a key in Azure Key Vault using the Azure CLI?

A

Use the az keyvault key rotate command:

bash
az keyvault key rotate --vault-name mykeyvault --name mykey

This generates a new key version based on the existing key policy.

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

What are some recommended best practices for managing Azure Key Vault to ensure security and operational efficiency?

A

Best practices include:
- Use separate vaults per application per environment (e.g., dev, prod).
- Control access with Microsoft Entra ID and RBAC or Key Vault access policies.
- Enable logging and alerts for monitoring.
- Enable soft-delete and purge protection to prevent accidental data loss.
- Regularly back up vaults on key/secret/certificate updates.

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

How do you create and implement a shared access signature (SAS) to provide delegated access to Azure Blob Storage resources?

A

Use the Azure Storage SDK for .NET:
```csharp
using Azure.Storage.Blobs;

var blobServiceClient = new BlobServiceClient(“connection_string”);
var containerClient = blobServiceClient.GetBlobContainerClient(“mycontainer”);
var sasBuilder = new BlobSasBuilder
{
BlobContainerName = containerClient.Name,
Resource = “c”, // Container-level SAS
StartsOn = DateTimeOffset.UtcNow,
ExpiresOn = DateTimeOffset.UtcNow.AddHours(1),
Protocol = SasProtocol.Https,
Permissions = BlobSasPermissions.Read | BlobSasPermissions.Write
};
var sasToken = containerClient.GenerateSasUri(sasBuilder);
Console.WriteLine($”SAS URI: {sasToken}”);
```
This generates a SAS token for read/write access to the container for one hour, secure via HTTPS.

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

How do you implement a solution using .NET to interact with Microsoft Graph to retrieve user profile data?

A

Use the Microsoft.Graph SDK with MSAL for authentication:
1. Register an app in Microsoft Entra ID and get client ID/secret.
2. Authenticate and acquire a token:
```csharp
using Microsoft.Identity.Client;
using Microsoft.Graph;

var app = PublicClientApplicationBuilder
.Create(“your_client_id”)
.WithAuthority(“https://login.microsoftonline.com/your_tenant_id”)
.Build();
var scopes = new[] { “User.Read” };
var result = await app.AcquireTokenInteractive(scopes).ExecuteAsync();
string accessToken = result.AccessToken;

var graphClient = new GraphServiceClient(new DelegateAuthenticationProvider(
requestMessage =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue(“Bearer”, accessToken);
return Task.CompletedTask;
}));
var user = await graphClient.Me.Request().GetAsync();
Console.WriteLine($”User: {user.DisplayName}”);
```
This retrieves the current user’s profile using Microsoft Graph.

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

What are the primary differences between Azure AD for developers (v1.0) and the Microsoft Identity Platform (v2.0) in terms of authentication and target audiences?

A
  • Azure AD for Developers (v1.0):
    • Uses Azure AD Authentication Library (ADAL), Entra ID endpoint (v1.0), and targets work/school accounts via Active Directory Federation Services (AD FS).
    • Limited to Azure AD tenants, using older protocols and libraries.
  • Microsoft Identity Platform (v2.0):
    • Uses Microsoft Authentication Library (MSAL), Microsoft Entra endpoint, and supports work/school accounts, personal Microsoft accounts, social accounts (Azure AD B2C), and local accounts (Entra External ID).
    • Offers broader audience support, modern protocols, and unified authentication across platforms.
      V2.0 is recommended for new applications due to its flexibility and broader compatibility.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you enable customer-managed key capability for Azure Key Vault to encrypt app configuration data?

A

Use the Azure CLI to enable customer-managed keys:
1. Create a key vault:

bash
   az keyvault create --name mykeyvault --resource-group myResourceGroup --location eastus
  

2. Create a key for encryption:
bash
   az keyvault key create --vault-name mykeyvault --name mykey --protection software
  

3. Enable customer-managed keys for an Azure resource (e.g., App Service):
bash
   az webapp identity assign --name mywebapp --resource-group myResourceGroup
   az keyvault set-policy --name mykeyvault --object-id <app-identity-object-id> --key-permissions get list update
  

This allows the app to use Key Vault keys for encryption via Managed Identity.

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

How do you configure an Azure application to use Azure Key Vault keys for securing app configuration data?

A

Configure the application to use Key Vault keys via Managed Identity:
1. Enable system-assigned identity for the app:

bash
   az webapp identity assign --name mywebapp --resource-group myResourceGroup
  

2. Grant access to Key Vault:
bash
   az keyvault set-policy --name mykeyvault --object-id <app-identity-object-id> --key-permissions get list
  

3. Use the .NET SDK to access keys:
```csharp
using Azure.Security.KeyVault.Keys;

var client = new KeyClient(new Uri(“https://mykeyvault.vault.azure.net/”), new DefaultAzureCredential());
KeyVaultKey key = await client.GetKeyAsync(“mykey”);
Console.WriteLine($”Key: {key.Name}”);
```
This secures configuration data using Key Vault keys.

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

How do you configure private endpoints for Azure App Configuration to secure app configuration data?

A

Use Azure CLI to create a private endpoint:
1. Create an App Configuration store:

bash
   az appconfig create --name myappconfig --resource-group myResourceGroup --location eastus
  

2. Create a private endpoint in a virtual network:
bash
   az network private-endpoint create \
     --name myprivateendpoint \
     --resource-group myResourceGroup \
     --vnet-name myvnet \
     --subnet mySubnet \
     --private-connection-resource-id /subscriptions/<sub-id>/resourceGroups/myResourceGroup/providers/Microsoft.AppConfiguration/configurationStores/myappconfig \
     --group-ids configurationStores
  

This restricts access to the App Configuration store via a private network, enhancing security.

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

How do you programmatically manage certificates in Azure Key Vault using the .NET certificates client library, including create, update, list, and delete operations?

A

Use the Azure.Security.KeyVault.Certificates library:
```csharp
using Azure.Security.KeyVault.Certificates;

var client = new CertificateClient(new Uri(“https://mykeyvault.vault.azure.net/”), new DefaultAzureCredential());

// Create a certificate
var createParameters = new CertificateCreateParameters(“mycert”, new X509Certificate2(“path/to/cert.pfx”));
CertificateOperation operation = await client.StartCreateCertificateAsync(createParameters);
await operation.WaitForCompletionAsync();

// List certificates
AsyncPageable<CertificateWithPolicy> certificates = client.GetCertificatesAsync();
await foreach (var cert in certificates)
{
Console.WriteLine($"Certificate: {cert.Name}");
}</CertificateWithPolicy>

// Update certificate policy
var policy = await client.GetCertificatePolicyAsync(“mycert”);
policy.Subject = “CN=UpdatedSubject”;
await client.UpdateCertificatePolicyAsync(“mycert”, policy);

// Delete certificate
await client.DeleteCertificateAsync(“mycert”);
```
This manages certificates, policies, issuers, and contacts programmatically.

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

How do you manage keys in Azure Key Vault using the .NET keys client library, including creating, retrieving, updating, deleting, and handling RSA and EC keys?

A

Use the Azure.Security.KeyVault.Keys library:
```csharp
using Azure.Security.KeyVault.Keys;

var client = new KeyClient(new Uri(“https://mykeyvault.vault.azure.net/”), new DefaultAzureCredential());

// Create an RSA key
KeyVaultKey rsaKey = await client.CreateRsaKeyAsync(“myrsakey”, new CreateRsaKeyOptions { KeySize = 2048 });

// Create an EC key
KeyVaultKey ecKey = await client.CreateEcKeyAsync(“myeckey”, new CreateEcKeyOptions { CurveName = KeyCurveName.P256 });

// Retrieve a key
KeyVaultKey retrievedKey = await client.GetKeyAsync(“myrsakey”);
Console.WriteLine($”Key: {retrievedKey.Name}”);

// Update key properties
var key = await client.GetKeyAsync(“myrsakey”);
await client.UpdateKeyPropertiesAsync(key.Properties, enabled: false);

// Delete key
await client.DeleteKeyAsync(“myrsakey”);
await client.PurgeDeletedKeyAsync(“myrsakey”);
```
This supports RSA and EC keys with full lifecycle management.

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

How do you manage secrets in Azure Key Vault using the .NET secrets client library, including creating, retrieving, updating, deleting, and handling versions?

A

Use the Azure.Security.KeyVault.Secrets library:
```csharp
using Azure.Security.KeyVault.Secrets;

var client = new SecretClient(new Uri(“https://mykeyvault.vault.azure.net/”), new DefaultAzureCredential());

// Create a secret
KeyVaultSecret secret = await client.SetSecretAsync(“mysecret”, “mysecretvalue”);

// Retrieve a secret
KeyVaultSecret retrievedSecret = await client.GetSecretAsync(“mysecret”);
Console.WriteLine($”Secret: {retrievedSecret.Value}”);

// Update a secret
await client.UpdateSecretAsync(“mysecret”, new SecretProperties { Value = “newsecretvalue” });

// Delete a secret
await client.DeleteSecretAsync(“mysecret”);
await client.PurgeDeletedSecretAsync(“mysecret”);
```
This manages secrets like tokens and passwords securely.

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

How do you create and enable a system-assigned managed identity for an Azure virtual machine, including the required role assignment?

A

Use the Azure CLI:
1. Create or update a VM with a system-assigned identity:

bash
   az vm create \
     --resource-group myResourceGroup \
     --name myvm \
     --image UbuntuLTS \
     --assign-identity
  

2. Ensure your account has the Virtual Machine Contributor role (no additional Azure AD roles needed):
bash
   az role assignment create \
     --assignee <your-user-object-id> \
     --role "Virtual Machine Contributor" \
     --resource-group myResourceGroup
  

This enables the identity for Azure AD authentication.

18
Q

What are the key features of Stored Access Policies in Azure Storage, and how do they enhance the management of shared access signatures (SAS) tokens?

A

Stored Access Policies in Azure Storage offer:
- Grouping SAS Tokens: Manage multiple SAS tokens under one policy for easier permission updates.
- Control Over Parameters: Set start time, expiry time, and permissions for SAS tokens via the policy.
- Revoking Access: Revoke SAS tokens by updating or deleting the policy, without changing account keys.
- Supported Resources: Apply to blob containers, file shares, queues, and tables.
They enhance SAS token management by providing centralized control, flexible revocation, and consistent permissions across resources.

19
Q

How should you configure an Azure Function to ensure only authorized clients can invoke it in a real-time mobile tracking application that uses Azure Web PubSub for data streaming?

A

Implement Azure AD authentication for the Azure Function because:
- It ensures only authenticated clients can invoke the function by validating Azure AD tokens.
- Integrates seamlessly with Azure Web PubSub, which can also use Azure AD for client authentication.
- Provides enterprise-grade security with support for various authentication flows.
Other options like SAS (better for Storage), HTTP header whitelisting, or IP restrictions don’t offer the same level of secure, identity-based access control.

20
Q

What configuration should you apply to an Azure App Service web app to securely access Azure Key Vault without embedding credentials?

A

Assign a managed identity to the App Service and configure Key Vault access policies because:
- Managed identity eliminates credential management by using Azure AD authentication.
- The App Service can obtain tokens to access Key Vault securely.
- Key Vault access policies grant specific permissions (e.g., get, list) to the identity.
Other options like service endpoints, storing secrets in settings, or Azure AD app registrations are less secure or more complex.

21
Q

What three attributes should you configure in a web application using the Microsoft identity platform to enable it to request tokens for APIs?

A

Configure these three attributes:
- Application ID: Uniquely identifies the app in Azure AD for authentication.
- Redirect URI: Specifies where to redirect users after authentication in OAuth flows.
- Client Secret: Secures the app’s identity for token requests.
Other options like tenant ID, resource endpoint, or application name aren’t directly required for token requests.

22
Q

What parameter or configuration is critical for enabling delegated access during the OAuth 2.0 flow in a web app using the Microsoft identity platform to access a user’s calendar and send meeting invites?

A

Use the scope parameter because:
- It defines the permissions (e.g., Calendars.ReadWrite, Mail.Send) the app requests.
- Ensures the access token includes delegated access to act on the user’s behalf.
- Aligns with least privilege by requesting only necessary permissions.
Other options like redirect URI, access_type, or grant_type don’t specify permissions.

23
Q

How does the scope parameter enable delegated access in the OAuth 2.0 flow for a web app using the Microsoft identity platform?

A

The scope parameter in OAuth 2.0:
- Specifies permissions (e.g., Calendars.Read, Mail.Send) the app needs to act on the user’s behalf.
- Presents a consent screen to the user, granting delegated access upon approval.
- Ensures the access token includes only the requested permissions, enhancing security.
It’s essential for enabling specific actions like accessing calendars or sending invites.

24
Q

Which claim should you prioritize to ensure reliable user identification across tenants in a multi-tenant Azure web app using the Microsoft identity platform?

A

Prioritize the tid (tenant ID) claim because:
- It uniquely identifies the Azure AD tenant the user belongs to.
- Ensures user identification across tenants, preventing conflicts in multi-tenant apps.
- Supports data isolation and security by segregating tenant-specific resources.
Other claims like oid, upn, or sid don’t provide tenant-level identification.

25
Why is the tid claim important for a multi-tenant Azure web app using the Microsoft identity platform for authentication?
The **tid (tenant ID)** claim is important because: - It uniquely identifies the tenant, ensuring reliable user identification across tenants. - Enables data isolation by segregating tenant-specific resources and permissions. - Supports compliance and auditing by tracking actions per tenant. It’s critical for maintaining security and isolation in multi-tenant architectures.
26
What API Management policy should you configure to enforce strict certificate validation for all incoming requests to a service in Azure API Management?
Configure the **authentication-certificate** policy because: - It verifies that incoming requests have a valid client certificate. - Ensures only authenticated clients with trusted certificates can access the API. - Meets security requirements for sensitive operations by enforcing client identity validation. Other policies like validate-jwt, validate-claims, or validate-https don’t handle certificate-based authentication.
27
How does the authentication-certificate policy in Azure API Management secure a service requiring strict client identity validation?
The **authentication-certificate** policy in Azure API Management: - Enforces client certificate authentication for all incoming requests. - Validates certificates against criteria like trusted issuer and expiration date. - Ensures only authorized clients can access the API, protecting sensitive operations. It’s ideal for securing services with strict identity verification needs.
28
What configuration should you apply to ensure critical application components on Azure Virtual Machines (VMs) across availability zones remain operational during a zone failure?
Set up a **scale set with zone redundancy enabled** because: - It distributes VMs across multiple availability zones in a region. - Ensures VMs in other zones remain operational if one zone fails. - Integrates with Azure Load Balancer to reroute traffic, maintaining availability. Other options like a single Availability Set, separate Resource Groups, or disk replication don’t provide zone-level redundancy.
29
How does zone redundancy in Azure Virtual Machine Scale Sets (VMSS) ensure application availability during a zone failure?
**Zone redundancy** in Azure VMSS: - Distributes VMs across multiple availability zones in a region. - Keeps VMs in other zones running if one zone fails, ensuring continuity. - Works with Azure Load Balancer to reroute traffic to operational VMs. It’s essential for high-availability applications in multi-zone deployments.
30
What token type and validation method should you implement in Azure API Management to enforce authentication for all API calls using tokens issued by Azure Active Directory?
Use **JSON Web Token (JWT)** validated with the **Azure AD OpenID Connect metadata endpoint** because: - JWT is a standard, self-contained token for secure authentication. - The OpenID Connect metadata endpoint provides public keys to validate token authenticity. - Ensures all API calls are authenticated via Azure AD securely. Other options like OAuth tokens with certificates, SAS tokens, or Kerberos don’t align with Azure AD best practices.
31
How does validating a JSON Web Token (JWT) using the Azure AD OpenID Connect metadata endpoint secure API calls in Azure API Management?
**JWT validation** with the Azure AD OpenID Connect metadata endpoint: - Uses public keys from the endpoint to verify the token’s signature and authenticity. - Confirms the token was issued by Azure AD, ensuring trusted authentication. - Enables secure, stateless API access for distributed applications. It’s a standard method for enforcing Azure AD authentication in API Management.
32
What parameter must a developer provide during registration of a mobile app using OAuth 2.0 implicit grant flow to ensure it can handle authentication responses?
Provide the **Redirect URI** because: - It specifies where the authorization server redirects the user after authentication. - Ensures the app can receive and parse the access token or error response. - Enhances security by preventing unauthorized redirects. Other options like Scope, Client secret, or Tenant ID don’t handle response redirection.
33
How does the Redirect URI ensure a mobile app using OAuth 2.0 implicit grant flow can handle authentication responses?
The **Redirect URI**: - Defines the endpoint where the authorization server sends the access token or error. - Must match the registered URI to prevent unauthorized redirects, ensuring security. - Allows the app to parse the response and proceed with authentication. It’s critical for secure and functional OAuth 2.0 implicit grant flow in mobile apps.
34
What Azure service provides the best solution for a global point-of-sale (POS) system collecting telemetry data from thousands of devices daily, associating data with unique identifiers?
Use **Azure IoT Hub with device twins** because: - IoT Hub scales to handle thousands of devices and real-time telemetry data. - Device twins provide unique identifiers (Device ID) to associate data with each device. - Supports secure, bi-directional communication and integration with other Azure services. Other options like Event Grid, Event Hubs, or Storage Queues lack device management features.
35
How does Azure IoT Hub with device twins support collecting and storing telemetry data from a global point-of-sale (POS) system?
**Azure IoT Hub with device twins**: - Manages thousands of devices with unique Device IDs for data association. - Collects real-time telemetry data securely with bi-directional communication. - Integrates with services like Stream Analytics or Blob Storage for processing and storage. It’s ideal for scalable, secure telemetry collection in a global POS system.
36
What approach should you choose to create a secure and scalable authentication system for a SaaS application using Azure AD, supporting multiple tenants?
Use **Azure AD Multi-tenant app registration** for cross-tenant access because: - Allows users from multiple tenants to authenticate with their own Azure AD credentials. - Scales efficiently with a single codebase for all tenants. - Enhances security with Azure AD features like MFA and Conditional Access. Other options like Azure AD B2C per tenant, Managed Identity, or separate tenants are less scalable or secure.
37
How does Azure AD Multi-tenant app registration support a secure and scalable authentication system for a multi-tenant SaaS application?
**Azure AD Multi-tenant app registration**: - Enables cross-tenant access with users’ existing Azure AD credentials. - Scales with a single app instance, reducing maintenance overhead. - Secures authentication with Azure AD features like MFA and Identity Protection. It’s ideal for efficient, secure multi-tenant authentication in SaaS apps.
38
What method should you use to enforce client authentication for an API hosted on Azure App Service to ensure only authenticated clients can access it?
Use **Azure Active Directory B2C** to authenticate users because: - Provides secure OAuth2 and OpenID Connect authentication with token-based access. - Supports MFA, social logins, and user management for enhanced security. - Scales for large user bases with flexible user flows and policies. Other options like API keys, OAuth2 with AAD, or Basic Authentication are less secure or outdated.
39
How does Azure Active Directory B2C ensure secure client authentication for an API hosted on Azure App Service?
**Azure Active Directory B2C**: - Uses OAuth2 and OpenID Connect for secure token-based authentication. - Enhances security with MFA, social logins, and compliance features. - Manages user roles and permissions for granular access control. It’s ideal for secure, scalable API authentication in modern applications.
40
Which Azure service should you use to ingest, buffer, and process large data transfers in real-time with minimal latency?
Use **Azure Event Hub with a custom processor** because: - Handles millions of events per second for high-throughput data ingestion. - Enables real-time processing with low latency and parallel event handling. - Integrates with Stream Analytics or custom logic for tailored processing. Other options like Storage Queues, Data Lake, or Logic Apps aren’t optimized for real-time processing.
41
How does Azure Event Hub with a custom processor handle large data transfers with minimal latency in real-time?
**Azure Event Hub with a custom processor**: - Ingests millions of events per second with high throughput and low latency. - Processes data in real-time using parallel partitions and custom logic. - Scales dynamically to handle large data volumes efficiently. It’s ideal for real-time, high-volume data processing in Azure.