I have one Storage Account in one Azure Resource Group. How to grant access to SA for newly created VMs in this Resource group automatically?
The idea as soon as VM was created it provides access to SA where I would like to store some configuration files.
Create a user-managed identity with the role
Storage Blob Data Contributorand assign it to the particular storage account.Portal:
Now, after creating a Virtual Machine, you need to add the user-managed identity to your virtual machine manually.
Command:
Output:
Portal:
Now, after assigning identity to the VM, the virtual machine can access the storage account.
Here, you can refer to this SO-thread by Sourav to access the storage account using managed identity.