【问题标题】:Automatically publishing cloud service to Azure using TFS15使用 TFS15 自动将云服务发布到 Azure
【发布时间】:2016-05-26 16:53:21
【问题描述】:

过去几天我一直致力于构建系统,该系统可以将网站持续部署到 Azure 上的暂存系统。我相信我已经很接近它的工作了,但是当 Azure 尝试使用 MSDeploy 扩展配置网站时出现错误。

我的流程概述:

使用 Team Foundation Server 2015(自托管,而非 VSO),我创建了一个包含“Visual Studio 构建”步骤的构建定义:

这会使用参数运行 MSBuild:

/p:DeployOnBuild=true /p:WebPublishMethod=包 /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true

这将创建一个名为 WebRole1.zip 的 ZIP 文件,可以在 $(Build.ArtifactStagingDirectory)\AzureTestBuilds\WebRole1.zip 找到该文件

Link to ZIP if anyone cares

接下来,构建使用 Powershell 脚本连接到 Azure,将上述 ZIP 文件上传到存储 Blob,并使用基于 JSON 的模板预配站点。该模板具有以下用于部署站点的 MSDeploy 扩展:

   "resources": [
      {
          "apiVersion": "2014-06-01",
          "type": "Extensions",
          "name": "MSDeploy",
          "dependsOn": [
              "[resourceId('Microsoft.Web/sites', variables('WebAPIURL'))]"
          ],
          "properties": {
            "packageUri": "[concat(variables('SiteStagingStorageURL'), '/zips/WebRole1.zip', parameters('sasToken'))]",
            "dbType": "None",
            "connectionString": "",
            "setParameters": {
              "Application Path": "[variables('WebAPIURL')]"
            }
          }
      }
   ]

构建运行时,我收到以下错误:

下午 4:21:31 - 资源 Microsoft.Web/sites/Extensions 'xxx-WebAPI/MSDeploy' 失败并显示消息'资源操作 已完成,终端配置状态为“失败”。

在 Kudu(Azure 诊断控制台)中,我看到一个更详细的错误:

<?xml version="1.0" encoding="utf-8"?>
<entries>
    <entry time="2016-02-13T00:21:51.3365955+00:00" type="Message">
        <message>Downloading metadata for package path 'zips/WebRole1.zip' from blob 'https://xxx.blob.core.windows.net'</message>
    </entry>
    <entry time="2016-02-13T00:21:51.8023866+00:00" type="Message">
        <message>The blob has flag IsPremiumApp:. IsPremiumApp returns False</message>
    </entry>
    <entry time="2016-02-13T00:21:51.8805277Z" type="Message">
        <message>Downloading package path 'zips/WebRole1.zip' from blob 'https://xxx.blob.core.windows.net'</message>
    </entry>
    <entry time="2016-02-13T00:21:52.2711541Z" type="Error">
        <message>AppGallery Deploy Failed: 'Microsoft.Web.Deployment.DeploymentXmlException: The declared parameter 'Application Path' is not recognized.

   at Microsoft.Web.Deployment.DeploymentSyncParameterCollection.LoadFromFile(XPathNavigator nav, String fileName, Boolean ignoreExtraSetParameters)
   at Microsoft.Web.Deployment.DeploymentSyncParameterCollection.LoadXml(String xml)
   at Microsoft.Web.Deployment.WebApi.AppGalleryPackage.LoadSetParameters(DeploymentObject deploymentObject, IDictionary`2 setParams)
   at Microsoft.Web.Deployment.WebApi.AppGalleryPackage.Deploy(String deploymentSite, String siteSlotId)
   at Microsoft.Web.Deployment.WebApi.DeploymentController.&lt;DownloadAndDeployPackage&gt;d__b.MoveNext()'</message>
    </entry>
</entries>

据我所知,zip 的 XML 清单中的参数不正确。我花了很多时间阅读有关如何使用 MSDeploy 构建扩展在 Azure 上部署站点的各种博客和教程,但它们都使用现有的 sample ZIP 文件。我找不到有关这些 zip 文件和 XML 清单的正确格式的任何信息,也找不到如何使用 MSBuild 创建有效格式的信息。我在这里缺少一个步骤吗?我很乐意发布更多需要的信息。

【问题讨论】:

  • 报错提示“无法识别声明的参数'Application Path'”,是否尝试更改参数'Application Path'?
  • 如果您愿意的话,TFS 2015 Update 2 是具有上线许可证 (visualstudio.com/news/tfs2015-update2-vs) 的候选发布版,它包括当前在 VSTS 上可用的新的基于 Web 的发布管理功能。它使这种事情变得非常简单和更好,您可以将构建和发布过程解耦。
  • @rerwinRR - 哦,看起来很有希望。我正在运行 TFS15,想知道“升级”过程有多容易。它在虚拟机上运行,​​所以如果我把所有东西都搞砸了,我可以拍一张快照然后恢复..
  • @Cece-MSFT - 抱歉,我不知道该怎么做。
  • @MikeChristensen,对不起,我不熟悉 JSON 语法,但由于日志抱怨声明的参数“应用程序路径”,您可以尝试给“应用程序路径”一个特定的值,看看您是否会得到同样的错误。

标签: azure tfs msbuild tfsbuild tfs-2015


【解决方案1】:

JSON 值可以是:

A number (integer or floating point)
A string (in double quotes)
A Boolean (true or false)
An array (in square brackets)
An object (in curly braces)
null

但您似乎在 value 字段中使用了 Function (variables('WebAPIURL'))。恐怕是问题所在。

【讨论】:

    【解决方案2】:

    想通了。我必须将一个名为parameters.xml 的文件添加到项目的根文件夹(与web.configGlobal.asax 相同的文件夹。该文件包含以下内容:

    <parameters>
      <parameter name="Application Path" description="Full site path where you would like to install your application (i.e., Default Web Site/WebRole1)" defaultValue="Default Web Site/WebRole1" tags="iisapp">
        <parameterEntry type="ProviderPath" scope="iisapp" match="WebRole1" />
      </parameter>
      <parameter name="SetAclParameter1" description="Hidden - automatically sets write access for the app" defaultValue="{Application Path}/App_Data" tags="Hidden, NoDatabase">
        <parameterEntry type="ProviderPath" scope="setAcl" match="WebRole1/App_Data" />
      </parameter>
    </parameters>
    

    WebRole1 更改为您的 Web 项目的名称。 MSDeploy 似乎只是自动获取此文件,无需更改任何其他设置或构建参数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-17
      • 2017-04-08
      • 2015-08-15
      相关资源
      最近更新 更多