So I have a PowerShell Script, that works with an Service Principal, and tries to get all Recovery Service Vaults in a specific Subscription. Therefor the Service Principal has the following permission in Azure: 'Microsoft.RecoveryServices/Vaults/read'. The Scope is the Subscription.
When I try to fetch the data from Azure with the following Command I dont get any result: Get-AzRecoveryServicesVault
With my Admin Account (Contributor rights), the Script, returns the Recovery Service Vaults. Also, when I use Azure Graph Search-AzGraph -Query "Resources | where type =~ 'Microsoft.RecoveryServices/vaults'"
with the Service Principal I get the expected result, only issue seems to be that the Get-AzRecoveryServicesVault
doesnt work.
Am I missing anything?
If you receive empty results, it could be because you entered the wrong subscription details or that the subscription you selected did not include any recovery service vaults.
Check below to resolve the issue:
Clear-AzContext -Force
command once you logged into the account usingConnect-AzAccount
.Reader
role to the Service Principal andBackup Operator
role at the vault level to the Service Principal.After checking all the above, I tried retrieving the expected results with
Get-AzRecoveryServicesVault
command and was successful as shown.