我正在尝试使用Azure powershell中的cmdlet创建一个VM。
New-AzureRmResourceGroupDeployment -Name VmDeployment -ResourceGroupName ABC `
-TemplateFile "C:\Templates\template.json" `
-TemplateParameterFile "C:\Templates\parameters.json"
此cmdlet似乎在大多数情况下都有效,但有时会出现以下错误。
New-AzureRmResourceGroupDeployment : An error occurred while sending the request.
At line:1 char:1
+ New-AzureRmResourceGroupDeployment -Name VmDeployment1 -ResourceGroup ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmResourceGroupDeployment], HttpRequestException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet.
此错误消息没有任何相关信息,说明为什么这个失败。
我尝试运行cmdlet几次,它再次工作。我似乎不明白为什么即使脚本没有变化,这有时也不起作用。
几乎没有其他cmdlet具有相同的问题。但是例如,我只提到了一个。
任何输入都非常感谢。谢谢
New-AzureRmResourceGroupDeployment
cmdlet的一些问题,有时它无法给出正确的错误消息。
因此,作为一种解决方法,您应该尝试在其命令中提到的4c74356b41重新安装(或)更新Azure PowerShell模块。
另外,另一种选择是在执行$DebugPreference="Continue"之前使用New-AzureRmResourceGroupDeployment
这将确定PowerShell如何响应脚本,cmdlet或提供程序生成的调试消息,或命令行中的Write-Debug命令
例如,这将给出一些细节错误消息,如下所示
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
NotFound
Headers:
Pragma : no-cache
x-ms-failure-cause : gateway
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-request-id : 65972d3e-495e-41fd-84fd-9b068c62df22
x-ms-correlation-request-id : 65972d3e-xx-41fd-84fd-xx
x-ms-routing-request-id : xxx:xxx:65972d3e-xx-41fd-84fd-xx
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
Cache-Control : no-cache
Date : Tue, 04 Sep 2018 02:45:49 GMT
Body:
{
"error": {
"code": "ResourceGroupNotFound",
"message": "Resource group 'test' could not be found."
}
}
你可以在github找到类似的问题