I am trying to access an Azure Storage resource from an Azure Windows VM using a Managed Identity.
I have followed the instructions here https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-vm-windows-access-storage but the Access section in the tutorial is done using .NET, which I'm unfamiliar with.
Instead, I would like to list the content of the blob using a combination of Powershell and Managed Identity from the VM, as this fits my use case. Is this possible, because I can't seem to find any example online? If it is, does anyone have a working example please?
Thanks in advance.
CodePudding user response:
I believe you have fulfilled all the prerequisites
- Enable system-assigned managed identity on Azure Windows VM. https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-vm-windows-access-storage#enable
- Grant your VM system-assigned managed identity to an Azure Storage container. https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-vm-windows-access-storage#grant-access-1
To access the content of the blob using Powershell you can use following commands:
Connect-AzAccount -Identity
#Get blobs in a container by using the pipeline
Get-AzStorageContainer -Name container* | Get-AzStorageBlob -IncludeDeleted
https://docs.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount?view=azps-7.4.0 https://docs.microsoft.com/en-us/powershell/module/az.storage/get-azstorageblob?view=azps-7.4.0