| author | WilliamDAssafMSFT |
|---|---|
| ms.author | wiassaf |
| ms.reviewer | rotabor, alexwolf |
| ms.date | 06/01/2023 |
| ms.service | azure-sql-database |
| ms.topic | include |
| ms.custom | generated, devx-track-azurecli |
Use the following Azure CLI commands to associate an identity with your app:
Retrieve the fully qualified resource ID of the managed identity you created using the az identity show command. Copy the output value to use in the next step.
az identity show --name MigrationIdentity -g <your-identity-resource-group-name> --query id
You can assign a managed identity to an Azure App Service instance with the az webapp identity assign command. The --identities parameter requires the fully qualified resource ID of the managed identity you retrieved in the previous step. A fully qualified resource ID starts with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.
az webapp identity assign \
--resource-group <resource-group-name> \
--name <webapp-name> \
--identities <managed-identity-id>
If you are working with Git Bash, be careful of path conversions when using fully qualified resource IDs. To disable path conversion, add MSYS_NO_PATHCONV=1 to the beginning of your command. For more information, see Auto translation of resource IDs.
You can assign a managed identity to your Azure Spring Apps instance using the az spring app identity assign command in the Azure CLI.
az spring app identity assign \
--resource-group <resource-group-name> \
--name <app-name> \
--service <service-name> \
--user-assigned <managed-identity-id>
You can assign a managed identity to a virtual machine with the az containerapp identity assign command.
az containerapp identity assign \
--resource-group <resource-group-name> \
--name <app-name> \
--user-assigned <managed-identity-id>
You can assign a managed identity to a virtual machine with the az vm identity assign command.
az vm identity assign \
--resource-group <resource-group-name> \
--name <virtual-machine-name> \
--identities <managed-identity-id>
You can assign a managed identity to an Azure Kubernetes Service (AKS) instance with the az aks update command.
az aks update \
--resource-group <resource-group-name> \
--name <cluster-name> \
--enable-managed-identity \
--assign-identity <managed-identity-id> \
--assign-kubelet-identity <managed-identity-id>