Connect-AzAccount using service principle

Sameer Bhat 126 Reputation points Microsoft Employee
2021-10-19T15:37:39.59+00:00

Hi Everyone,

I'm trying to login using service principle for Connect-AzCccount

Connect-AzAccount -Tenant $tenantId -Subscription $subscription -Credential $psCredential -ServicePrincipal

The login is successful, however I'm not able to execute the Set-AzKeyVaultManagedStorageSasDefinition.

Set-AzKeyVaultManagedStorageSasDefinition -AccountName $staccname -VaultName $kvname `
-Name $SASDefinitionName -TemplateUri $sasToken -SasType 'account' -ValidityPeriod ([System.Timespan]::FromDays(1))

Below is the error I'm getting. I have given permission to keyvault on storage account as well as permission to service principle to keyvault. Not sure why this error is again popping up. If I use normal login using Connect-AzAccount, then everything works fine. Only issue comes when I login using service principle. Can someone let me know what am i missing in here. Permission to keyvault /storage account / service principle are already give. If anything I'm missing let me know. Thanks

141846-image.png

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,107 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,679 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,438 questions
{count} votes

Accepted answer
  1. Sumarigo-MSFT 43,411 Reputation points Microsoft Employee
    2021-10-20T07:42:45.987+00:00

    @Sameer Bhat Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    Based on the error message Add-AzKeyVaultManagedStorageAccount : Operation returned an invalid status code 'Forbidden' there is a similar thread discussion, please refer to the troubleshooting steps and let me know the status.

    Also check in the access policy->Select principal is been added
    141956-image.png

    You can also refer to this thread it explains How RBAC works and designed.

    You can provide  or 142024-image.png

    You can check this article for a complete example: Add-AzureKeyVaultManagedStorageAccount

    Please let us know if you have any further queries. I’m happy to assist you further.
    Looking forward for your reply!

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------

    Please do not forget to 141928-image.png and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful