Azure - 使用arm模板从visual studio部署Web应用程序,连接到VSTS git源代码控制

时间:2017-09-04 09:59:56

标签: git azure templates arm

我正在尝试使用arm模板从visual studio部署azure web app(app services)。

这些是来自模板的资源:

"resources": [
      {
        "type": "Microsoft.Web/sites",
        "kind": "app",
        "name": "[parameters('site_name')]",
        "apiVersion": "2016-08-01",
        "location": "North Europe",       
        "scale": null,
        "properties": {
          "enabled": true,
          "hostNameSslStates": [
            {
              "name": "[concat(parameters('site_name'),'.azurewebsites.net')]",
              "sslState": "Disabled",
              "virtualIP": null,
              "thumbprint": null,
              "toUpdate": null,
              "hostType": "Standard"
            },
            {
              "name": "[concat(parameters('site_name'),'.scm.azurewebsites.net')]",
              "sslState": "Disabled",
              "virtualIP": null,
              "thumbprint": null,
              "toUpdate": null,
              "hostType": "Repository"
            }
          ],
          "serverFarmId": "[parameters('site_serverFarmId')]",
          "reserved": false,
          "siteConfig": null,
          "scmSiteAlsoStopped": false,
          "hostingEnvironmentProfile": null,
          "clientAffinityEnabled": true,
          "clientCertEnabled": false,
          "hostNamesDisabled": false,
          "containerSize": 0,
          "dailyMemoryTimeQuota": 0,
          "cloningInfo": null
        },
        "resources": [
          {
            "apiVersion": "2016-08-01",
            "name": "web",
            "type": "sourcecontrols",        
            "dependsOn": [
              "[resourceId('Microsoft.Web/Sites', parameters('site_name'))]"
            ],            
            "properties": {
              "repoUrl": "https://...",
              "branch": "master",
              "isManualIntegration": false              
            }
          }
        ],
        "dependsOn": []
      },
      {

            "type": "Microsoft.Web/sites/config",
            "name": "[parameters('config_web_name')]",
            "apiVersion": "2016-08-01",
            "location": "North Europe",

            "scale": null,
            "properties": {
                "numberOfWorkers": 1,
                "defaultDocuments": [
                    "Default.htm",
                    "Default.html",
                    "Default.asp",
                    "index.htm",
                    "index.html",
                    "iisstart.htm",
                    "default.aspx",
                    "index.php",
                    "hostingstart.html"
                ],
                "netFrameworkVersion": "v4.0",
                "phpVersion": "5.6",
                "pythonVersion": "",
                "nodeVersion": "",
                "linuxFxVersion": "",
                "requestTracingEnabled": false,
                "remoteDebuggingEnabled": false,
                "remoteDebuggingVersion": null,
                "httpLoggingEnabled": false,
                "logsDirectorySizeLimit": 35,
                "detailedErrorLoggingEnabled": false,
                "publishingUsername": "[concat('$',parameters('site_name'))]",
                "publishingPassword": null,
                "appSettings": null,
                "metadata": null,
                "connectionStrings": null,
                "machineKey": null,
                "handlerMappings": null,
                "documentRoot": null,
                "scmType": "VSO",
                "use32BitWorkerProcess": true,
                "webSocketsEnabled": false,
                "alwaysOn": false,
                "javaVersion": null,
                "javaContainer": null,
                "javaContainerVersion": null,
                "appCommandLine": "",
                "managedPipelineMode": "Integrated",
                "virtualApplications": [
                    {
                        "virtualPath": "/",
                        "physicalPath": "site\\wwwroot",
                        "preloadEnabled": false,
                        "virtualDirectories": null
                    }
                ],
                "winAuthAdminState": 0,
                "winAuthTenantState": 0,
                "customAppPoolIdentityAdminState": true,
                "customAppPoolIdentityTenantState": false,
                "runtimeADUser": null,
                "runtimeADUserPassword": null,
                "loadBalancing": "LeastRequests",
                "routingRules": [],
                "experiments": {
                    "rampUpRules": []
                },
                "limits": null,
                "autoHealEnabled": false,
                "autoHealRules": {
                    "triggers": null,
                    "actions": null
                },
                "tracingOptions": null,
                "vnetName": "",
                "siteAuthEnabled": false,
                "siteAuthSettings": {
                    "enabled": null,
                    "unauthenticatedClientAction": null,
                    "tokenStoreEnabled": null,
                    "allowedExternalRedirectUrls": null,
                    "defaultProvider": null,
                    "clientId": null,
                    "clientSecret": null,
                    "issuer": null,
                    "allowedAudiences": null,
                    "additionalLoginParams": null,
                    "isAadAutoProvisioned": false,
                    "googleClientId": null,
                    "googleClientSecret": null,
                    "googleOAuthScopes": null,
                    "facebookAppId": null,
                    "facebookAppSecret": null,
                    "facebookOAuthScopes": null,
                    "twitterConsumerKey": null,
                    "twitterConsumerSecret": null,
                    "microsoftAccountClientId": null,
                    "microsoftAccountClientSecret": null,
                    "microsoftAccountOAuthScopes": null
                },
                "cors": null,
                "push": null,
                "apiDefinition": null,
                "autoSwapSlotName": null,
                "localMySqlEnabled": false,
                "ipSecurityRestrictions": null
            },
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', parameters('site_name'))]"
            ]
        }
    ]

我有单独的模板用于创建资源组和服务计划。部署后,所有内容都在azure上正确生成,但Web应用程序未连接到源代码管理。只有默认的Web应用程序。

当我使用Web应用程序的部署选项时,会显示以下消息:未找到任何部署。 Web应用程序的资源组部署下有错误消息:参数x-ms-client-principal-name为null或为空。(代码:BadRequest)。

当我尝试通过azure portal进行相同的部署时,它就可以了。当我创建Web应用程序时,之后我只需要连接到源代码控制,并自动启动同步。

  1. 错误消息'参数x-ms-client-principal-name为空或为空。(代码:BadRequest)'是什么意思?如何更正?

  2. 是通过visual studio部署Web应用程序并将其连接到vsts git cource控件甚至可能吗?

1 个答案:

答案 0 :(得分:1)

取自我自己的问题:my answered question

您是从Visual Studio运行的吗? VSTS git是私有的 - 如果问题与我的相同,则向URL添加凭据将起作用。不要使用您的真实凭据。

在与克隆按钮相同的VSTS区域中创建别名凭据并使用这些凭据。您的网址应如下所示:

https://newAliasUserName:NewAliasPassword@####.visualstudio.com/####/####

祝你好运。