An organization requires a web application running on Azure App Service to query an Azure SQL Database. The security policy mandates the use of a user-assigned managed identity to eliminate hardcoded credentials. You must perform the configuration steps using the Azure CLI and SQL commands, and configure the .NET application code to connect securely. Which sequence of steps must you perform to provision, configure, and authenticate the application using the user-assigned managed identity?
- 1Create the user-assigned managed identity resource in your Azure subscription by executing the `az identity create` command.
- 2Assign the user-assigned managed identity to the Azure App Service web app by running the `az webapp identity assign` command.
- 3Connect to the Azure SQL Database and execute `CREATE USER [<identity-name>] FROM EXTERNAL PROVIDER` to create a contained database user, then add the user to the `db_datareader` role.
- 4Add an application setting named `AZURE_CLIENT_ID` containing the Client ID of the user-assigned managed identity to the App Service web app.
- 5Instantiate the `DefaultAzureCredential` class from the `Azure.Identity` library in the application startup code to establish the database connection.
Cevap
The correct sequence begins with creating the user-assigned managed identity using the CLI. Next, assign this identity to the Azure App Service web app. After that, create a contained user for the identity within the Azure SQL Database and grant the database reader role. Then, configure the App Service app settings by adding the client ID of the user-assigned identity to the client ID environment variable. Finally, write application code using the default Azure credential to connect to the database.
The correct sequence flows logically from infrastructure provisioning to application deployment. The identity must be created first before it can be assigned to the web app or authorized in the SQL Database. The app settings must be updated to reference the client ID before the application code is executed, allowing the default Azure credential to correctly resolve the user-assigned identity at runtime.
Adım Adım Çözüm
Anahtar Kavram
Configuring a user-assigned managed identity for App Service to access Azure SQL Database requires identity creation, resource association, target system authorization, runtime client ID configuration, and default SDK credential usage.