Issue
I am facing some problem to create a Bash Script regrading conditions & I am not work not enough in Bash . Please someone help to do this task
I have a 3 Environment in Azure like Test , Dev & Stage . I want to create user-managed Identities those 3 environment at the same same by bash Script . I want to assign user-managed Identity to Key Vault, App services , Service Bus & Event Hub by Basg
For Example: Test Tenant id : 7a610d29-a29a-4833-b40c-27b6120c3c57 Dev Tenant id : b6fc9b56-eb3d-4768-92e7-81ac62f8a7d1 Stage Tenant Id: 88501bf2-52be-46fd-b4d6-61967b489177
Someone help me to get of this task .
Thanks Emmi
Solution
To create User Managed Identity, make use of below script:
resourceGroup="ruk"
location="eastus"
identityName="testrukUI"
az identity create --resource-group $resourceGroup --name $identityName --location $location
User Managed identity created successfully:
To assign the User Managed Identity to Azure Key vault use the below command:
az keyvault set-policy --name testrukkvv33 --object-id ObjectIDofmanagedidentity --secret-permissions get list
To assign the User Managed Identity to Azure App Service use the below command:
az webapp identity assign -g ruk -n testrukwebapp33 --identities [system] "/subscriptions/SubID/resourceGroups/ruk/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testrukUI"
To assign user managed identity to Event hub and Service bus refer the below MsDocs:
az eventhubs namespace identity | Microsoft
az servicebus namespace identity | Microsoft
Answered By - Rukmini Answer Checked By - Marilyn (WPSolving Volunteer)