Microsoft

AI-103 practice question 4

Developing AI Apps and Agents on Azure · free question 4 of 20

Question

You have a Python application named App1 that integrates with a Microsoft Foundry project named Project1. You need to ensure that App1 meets the following requirements: - Authenticates by using a Microsoft Entra managed identity - Sends prompts to a deployed model by using the Azure OpenAI Responses API How should you complete the Python code? To answer, select the appropriate options in the answer area. ```python from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient credential = [Dropdown 1]() project_client = AIProjectClient( endpoint="https://contosoai.services.ai.azure.com/api/projects/project1", credential=credential, ) with project_client.get_openai_client() as openai_client: response = openai_client.responses.[Dropdown 2]( model="trail-guide-chat", input="Create a 3-day hiking itinerary near Seattle.", ) print(response.output_text) ``` NOTE: Each correct selection is worth one point.

Explanation

Dropdown 1: DefaultAzureCredential resolves Microsoft Entra credentials in order and supports managed identity, so App1 authenticates without any stored secret. AzureKeyCredential uses an API key rather than Entra ID, and ClientSecretCredential authenticates a service principal with a client secret rather than a managed identity. Dropdown 2: responses.create sends the model and input to generate a new response, and its result provides output_text. The retrieve method fetches an existing response by its ID, and compact reduces the context of an existing conversation, so neither sends this prompt.

Need the theory? Learn it free in the AI-103 course on Godlike Academy

Practice the whole free set

Answer all 20 free AI-103 questions with instant feedback, or unlock all 65 questions with Learn and Exam modes.