Microsoft AzureをPowerShellで操作する際に表示されるエラー対処

PowerShell操作時、次のエラーが表示される。

Get-AzureVM : ForbiddenError: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this su
bscription.

サブスクリプション発行設定ファイルをImportしていない状態のようです。

サブスクリプション発行設定ファイルを次のコマンドでダウンロードし

Get-AzurePublishSettingsFile

*.publishsettingsを任意のパスに保存してください。

Import-AzurePublishSettingsFile 'ファイルパス\*.publishsettings'を実施してください。

 

1つのアカウントで複数サブスクリプションを管理している場合、サブスクリプションを指定してから操作するとよさそうです。

Select-AzureSubscription -SubscriptionName 'サブスクリプション'