Azure powershell cmdlet 抛出 "An error occurred while sending the request."

标签 azure powershell azure-virtual-machine azure-powershell powershell-cmdlet

我正在尝试在 Azure powershell 中使用以下 cmdlet 创建虚拟机。

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

之前

This will determine how PowerShell responds to debugging messages generated by a script, cmdlet or provider, or by a Write-Debug command at the command line

例如,这将给出一些详细错误消息,如下所示

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中找到类似的问题

关于Azure powershell cmdlet 抛出 "An error occurred while sending the request.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52153109/

相关文章:

azure - 如何将dns设置为azure aks?

powershell - Get-Printer powershell cmdlet 返回的信息的来源是什么?

azure - arm模板virtualNetworkName创建附录问题

.net - 如何通过 Powershell 创建位图

windows - 批处理文件以读取具有特殊字符的 txt 并替换其中的单词

Azure:使用云服务或虚拟网络对虚拟机进行分组

sql-server - 将 Azure VM 迁移到另一个(SQL 版本升级)

powershell - 在 Powershell 中将用户分配给 Active Directory native 应用程序 - 'C

reactjs - 我如何在 azure 静态 Web 应用程序的生产中访问我的 React VITE ENV 变量?

azure - 如何在 Azure 通知中心中使用具有多个自定义属性的推送通知模板?