ARM模板-网站部署失败

ARM template - website deployment failure

我正在尝试使用 Azure 资源管理器 (ARM) 模板文件部署为 ASP.net 网站,但遇到了障碍。这是 Azure 的一项新兴功能,因此网络上没有太多关于它的专业知识,希望这里有人可以提供帮助。

我可以在新资源组中成功创建一个新站点(即 Microsoft.Web/sites 资源),即当我在 ARM 模板中定义一个网站时它可以工作,如下所示:

{
  "apiVersion": "2014-06-01",
  "name": "[parameters('siteName')]",
  "type": "Microsoft.Web/sites",
  "location": "[parameters('siteLocation')]",
  "tags": {
    "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource",
    "displayName": "Website"

  },
  "dependsOn": [
    "[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
  ],
  "properties": {
    "name": "[parameters('siteName')]",
    "serverFarm": "[parameters('hostingPlanName')]"
  }
}

当我尝试将 ASP.net 网站部署到其中时,我的问题就来了。这是我添加到我的 ARM 模板中的内容:

{
  "apiVersion": "2014-06-01",
  "name": "[parameters('siteName')]",
  "type": "Microsoft.Web/sites",
  "location": "[parameters('siteLocation')]",
  "tags": {
    "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource",
    "displayName": "Website"

  },
  "dependsOn": [
    "[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
  ],
  "properties": {
    "name": "[parameters('siteName')]",
    "serverFarm": "[parameters('hostingPlanName')]"
  },
  "resources": [
    {
      "apiVersion": "2014-06-01",
      "type": "extensions",
      "name": "MSDeploy",
      "dependsOn": [ "[concat('Microsoft.Web/sites/', parameters('siteName'))]" ],
      "properties": {
        "connectionString": "",
        "dbType": "",
        "packageUri": "file:///D:/svn/dh.PSP.Conductor/dh.PSP.Conductor.AzureResourceGroup/obj/Release/ProjectReferences/dh.PSP.Conductor.Api/package.zip"
      }
    }
  ]
}

我正在从 PowerShell 进行部署,但失败了:

New-AzureResourceGroup : 16:00:35 - Resource Microsoft.Web/sites/extensions 'ARMTest20150604/MSDeploy' failed with message 'The resource operation completed with terminal provisioning state 'Failed'.'

如果我查看门户,我会看到一个更有用的错误:

statusCode:Conflict statusMessage:{"status":"Failed","error":{"code":"ResourceDeploymentFailure","message":"The resource operation completed with terminal provisioning state 'Failed'."}}

然而,我 none 更清楚为什么会失败。谁能建议我如何进一步调查?

错在我(如你所料)。无法为 packageUri 引用本地文件属性,需要先将文件上传到 blob 存储。

我发现了其他有用的东西,可以通过浏览 https://websitename.scm.azurewebsites.net/DebugConsole、"cd logfiles\siteextensions\msdeploy"、打开 appManagerLog.xml 获得部署日志。那里有更多有用的信息。就我而言:

<entry time="2015-06-04T15:28:12.0718158+00:00" type="Error">
        <message>AppGallery Deploy Failed: 'System.UriFormatException: Invalid URI: The URI is empty.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.Web.Deployment.WebApi.AppGalleryPackage.IsPremiumApp()
   at Microsoft.Web.Deployment.WebApi.DeploymentController.CheckCanDeployIfAppIsPremium(AppGalleryPackageInfo packageInfo, Boolean&amp;amp; isPremium)'</message>
    </entry>
    <entry time="2015-06-04T15:28:12.1186872Z" type="Message">
        <message>Downloading package path 'D:\svn\dh.PSP.Conductor\dh.PSP.Conductor.AzureResourceGroup\obj\Release\ProjectReferences\dh.PSP.Conductor.Api\package.zip' from blob ''</message>
    </entry>
    <entry time="2015-06-04T15:28:12.1186872Z" type="Error">
        <message>Failed to download package.</message>
    </entry>