1
votes

I get an error when trying to set the azure subscription using the Windows PowerShell.

Set-AzureSubscription  -SubscriptionName  $azureSubscriptionName -CurrentStorageAccount $service_name

Set-AzureSubscription : ForbiddenError: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription. At line:1 char:1 + Set-AzureSubscription -SubscriptionName $azureSubscriptionName -CurrentStorage ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Set-AzureSubscription], CloudException + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.SetAzureSubscriptionCommand

I confirmed in the azure portal that the service I am giving as a parameter is in the subscription passed in $azureSubscriptionName.

Other fact is when I list Azure Subscriptions the CurrentStorageAccountName is empty.

Get-AzureSubscription

What is wrong on this command? How can I set the current storage account?

1

1 Answers

0
votes

I would suggest you have a look at this article: https://blogs.msdn.microsoft.com/goutham/2015/06/16/azure-powershell-forbiddenerror-the-server-failed-to-authenticate-the-request-verify-the-certificate-is-valid-and-is-associated-with-this-subscription/. Here is a snippet:

the below command does the magic of clearing your azure profile which is existing. Clear-AzureProfile. You can also consider deleting the content of the folder C:\Users\AppData\Roaming\Windows Azure Powershell manually. After which again run Add-AzureAccount to get the fresh/new one by entering your subscription details and then execute any Azure PowerShell commands that you wish to run

Hope this helps.