Azure 使用来自 VSTS Git 代码的 ARM 模板将代码部署到服务 [英] Azure Deploy Code To Service Using ARM Template From VSTS Git Code

查看:17
本文介绍了Azure 使用来自 VSTS Git 代码的 ARM 模板将代码部署到服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个 ARM 模板并将其用于:

I have created an ARM template and am using it to:

  • 创建资源组.
  • 创建和应用服务.
  • 将代码从 GitHub (repoUrl) 部署到所述应用服务.

当我将我的项目放在 GitHub 中时,一切都运行良好,但我们使用 VSTS Git 来保存我们的代码.我知道我可以创建一个 VSTS 作业来为我做这件事,这是我们将再次进入的轨道,但是我们需要能够从我们的开发人员机器运行这些 ARM 模板,直接从我们的 Visual Studios 或 Powershell ISE 运行.

All works wonderfully when I place my project inside GitHub but we are using VSTS Git to hold our code. I know I can create a VSTS jobs that will do this for me and this is the track we will get to again however we need to be able to run these ARM templates from our developer machines, running direct from our Visual Studios or Powershell ISE's.

几乎一切正常,直到它尝试将我的 C# 项目从 VSTS Git 添加到服务我收到以下平淡的错误报告:

Almost everything works until it tries to add my C# project from VSTS Git to the service I get the following bland error report:

New-AzureRmResourceGroupDeployment : 16:08:30 - Resource Microsoft.Web/sites/sourcecontrols 'webapp1nameuniques83476y4589479/web' failed with message '{
  "status": "Failed",
  "error": {
    "code": "ResourceDeploymentFailure",
    "message": "The resource operation completed with terminal provisioning state 'Failed'."
  }
}'At C:\Users\[removed my directory]\Deploy-AzureResources.ps1:119 char:5
+     New-AzureRmResourceGroupDeployment -Name ((Get-ChildItem $Templat ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet

New-AzureRmResourceGroupDeployment : 16:08:30 - Template output evaluation skipped: at least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.At 
C:\Users\[removed my directory]\Deploy-AzureResources.ps1:119 char:5
+     New-AzureRmResourceGroupDeployment -Name ((Get-ChildItem $Templat ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet

New-AzureRmResourceGroupDeployment : 16:08:30 - Template output evaluation skipped: at least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.At 
C:\Users\[removed my directory]\Deploy-AzureResources.ps1:119 char:5
+     New-AzureRmResourceGroupDeployment -Name ((Get-ChildItem $Templat ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet

我使用的模板是:

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "webapp1name": {
      "type": "string",
      "defaultValue": "webapp1nameuniques83476y4589479",
      "metadata": {
        "description": "The name of the web app that you wish to create."
      }
    },
    "webapp1hostingplan": {
      "type": "string",
      "defaultValue": "hostingplantestname",
      "metadata": {
        "description": "The name of the App Service plan to use for hosting the web app."
      }
    },
    "sku": {
      "type": "string",
      "allowedValues": [
        "F1",
        "D1",
        "B1",
        "B2",
        "B3",
        "S1",
        "S2",
        "S3",
        "P1",
        "P2",
        "P3",
        "P4"
      ],
      "defaultValue": "S1",
      "metadata": {
        "description": "The pricing tier for the hosting plan."
      }
    },
    "workerSize": {
      "type": "string",
      "allowedValues": [
        "0",
        "1",
        "2"
      ],
      "defaultValue": "0",
      "metadata": {
        "description": "The instance size of the hosting plan (small, medium, or large)."
      }
    },
    "repoURL": {
      "type": "string",
      "metadata": {
        "description": "The URL for the GitHub repository that contains the project to deploy."
      }
    },
    "branch": {
      "type": "string",
      "defaultValue": "master",
      "metadata": {
        "description": "The branch of the GitHub repository to use."
      }
    }
  },
  "resources": [
    {
      "apiVersion": "2015-08-01",
      "name": "[parameters('webapp1hostingplan')]",
      "type": "Microsoft.Web/serverfarms",
      "location": "[resourceGroup().location]",
      "sku": {
        "name": "[parameters('sku')]",
        "capacity": "[parameters('workerSize')]"
      },
      "properties": {
        "name": "[parameters('webapp1hostingplan')]"
      }
    },
    {
      "apiVersion": "2015-08-01",
      "name": "[parameters('webapp1name')]",
      "type": "Microsoft.Web/sites",
      "location": "[resourceGroup().location]",
      "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms', parameters('webapp1hostingplan'))]"
      ],
      "properties": {
        "serverFarmId": "[parameters('webapp1hostingplan')]"
      },
      "resources": [
        {
          "apiVersion": "2015-08-01",
          "name": "web",
          "type": "sourcecontrols",
          "dependsOn": [
            "[resourceId('Microsoft.Web/Sites', parameters('webapp1name'))]"
          ],
          "properties": {
            "RepoUrl": "[parameters('repoURL')]",
            "branch": "[parameters('branch')]",
            "IsManualIntegration": true
          }
        }
      ]
    }
  ]
}

它以创建的所有资源结束,但应用程序服务没有部署代码项目.

It ends with all resources created but the application service has no code project deployed to it.

知道我做错了什么吗?

推荐答案

这是由于托管在 VSTS 上的 Git 存储库不是公开的,它们是私有的 Git 存储库.

This is due to Git repo hosted on VSTS is not public, they are private Git repo.

解决方法是在 repo url 中添加凭据.

The workaround around is adding the credentials in the repo url.

这篇关于Azure 使用来自 VSTS Git 代码的 ARM 模板将代码部署到服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆