Skip to main content

AI-200 practice question · Secure, Monitor, and Troubleshoot Azure Solutions

An API hosted in Azure Container Apps calls an Azure OpenAI resource in Microsoft Foundry.

An API hosted in Azure Container Apps calls an Azure OpenAI resource in Microsoft Foundry. Security policy requires every model call to use a short-lived Microsoft Entra access token. The application code and configuration must not store, retrieve, or rotate any credential, including API keys, client secrets, and certificates. What should the developer implement?

  • AEnable a managed identity on the container app, grant it the Cognitive Services OpenAI User role on the resource, and get tokens with DefaultAzureCredential
  • BEnable a managed identity on the container app and use it to read the Azure OpenAI API key from Azure Key Vault for the api-key header
  • CRegister a service principal with a certificate, load the certificate from Azure Key Vault, and get tokens for it with CertificateCredential
  • DKeep the resource's API key in app settings and regenerate the primary and secondary keys every week with an automated rotation job
Show the answer and explanation

Correct answer: A) Enable a managed identity on the container app, grant it the Cognitive Services OpenAI User role on the resource, and get tokens with DefaultAzureCredential

A managed identity with an inference role such as Cognitive Services OpenAI User lets an Azure-hosted app call Azure OpenAI with short-lived Entra tokens, and the app never stores, retrieves, or rotates a credential. Getting a key or certificate from Key Vault, even through a managed identity, still means handling a credential.

Why each option is right or wrong

  • A) Correct. Azure creates a managed identity and rotates its credentials, so the app has nothing to store or retrieve. With the Cognitive Services OpenAI User role, the identity can make inference calls. On an Azure host, DefaultAzureCredential picks up the managed identity and gets short-lived bearer tokens.
  • B) Incorrect. The managed identity secures access to Key Vault, but the app still retrieves a long-lived API key and sends it to the model. That breaks both policy requirements: it retrieves a credential and doesn't use an Entra token for the model call.
  • C) Incorrect. This produces Entra tokens, but a service principal needs a client secret or certificate that the app retrieves and that you have to rotate. Microsoft recommends service principals for CI/CD pipelines and hosts outside Azure.
  • D) Incorrect. Rotating keys shortens how long each key stays valid, but the app still stores and sends a shared API key instead of an Entra access token, and the rotation job is credential management that the policy forbids.
Question type
Multiple choice (one answer)

Practise the full AI-200 exam

This question is one of a small free sample from the CertRidge AI-200 bank. Full practice exams match the real exam's length, time limit and domain weights, explain every option, and Review Mode re-drills the questions you miss.

Original question written from the official exam guide. Not affiliated with Microsoft; never copied from the real exam.