【发布时间】:2015-06-26 06:09:32
【问题描述】:
我正在自动创建 Azure 网站并希望设置定价层。我找到了几篇很好的文章(https://azure.microsoft.com/en-us/documentation/articles/powershell-azure-resource-manager/、http://www.troyhunt.com/2015/01/automating-web-hosting-creation-in.html),它们将我指向 Get-AzureResource,但我无法让它工作。
我最初在 Azure 0.8 Powershell 模块中遇到 AuthenticationFailed 错误,然后升级到 0.9.3。我现在收到两个不同的错误,具体取决于我提供给 Get-AzureResource 的参数。我尝试了不同的 ApiVersion 开关,发现我正在运行 2014-04-01-preview,这让我有点担心,并通过 Get-AzureSubscriptions 确认我的订阅支持 AzureResourceManager。我错过了什么?
PS > Switch-AzureMode AzureResourceManager
WARNING: The Switch-AzureMode cmdlet is deprecated and will be removed in a future release.
$DebugPreference="Continue"
PS > Get-AzureResource -OutputObjectFormat New
DEBUG: 3:21:09 PM - GetAzureResourceCmdlet begin processing with ParameterSet 'Lists the resources based on the
specified scope.'.
DEBUG: 3:21:09 PM - using account id '###'...
Get-AzureResource : One or more errors occurred.
At line:1 char:1
+ Get-AzureResource -OutputObjectFormat New
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AzureResource], AggregateException
+ FullyQualifiedErrorId : System.AggregateException,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementatio
n.GetAzureResourceCmdlet
PS > Get-AzureResource -Name NNNNNNN -ResourceGroupName Default-Web-EastUS -ResourceType Microsoft.Web/sites -ApiVersion 2015-05-01 -OutputObjectFormat New
DEBUG: 3:31:55 PM - GetAzureResourceCmdlet begin processing with ParameterSet 'Lists the resources based on thespecified scope.'.
DEBUG: 3:31:55 PM - using account id '#####'...
Get-AzureResource : {
"Error": {
"Code": "AuthenticationFailed",
"Message": "Authentication failed. The 'Authorization' header is not present or provided in an invalid format.",
"Target": null,
"Details": null
}
}
At line:1 char:1
+ Get-AzureResource -Name NNNNNNN -ResourceGroupName Default-Web-EastUS -Res ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureResource], ErrorResponseMessageException
+ FullyQualifiedErrorId : AuthenticationFailed,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.Get
AzureResourceCmdlet
【问题讨论】:
标签: powershell azure