Search code examples
gitazuretemplatesazure-resource-manager

Azure - deploy web app from visual studio using arm template, connected to VSTS git source control


I am trying to deploy azure web app (app services) from visual studio using arm template.

These are resources from template:

"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'))]"
            ]
        }
    ]

I have separate template for creating resource group and service plan. After deployment everything is generated correctly on azure, but web app is not connected to source control. There is only default web application.

When I go under deployment options of web app, there is message: No deployments found. There is error message under resource group deployments of web app: Parameter x-ms-client-principal-name is null or empty.(Code: BadRequest).

When I try doing the same deployment through azure portal then it is ok. When I create web app, after that I only have to connect is to source control, and sync is started automatically.

  1. What does error message 'Parameter x-ms-client-principal-name is null or empty.(Code: BadRequest)' means and how can I correct it?

  2. Is deploying web app through visual studio and connecting it to vsts git cource control even possible?


Solution

  • Taken from my own question here: my answered question.

    You are running from Visual Studio right? VSTS git is private - if the problem was the same as mine, adding credentials to the URL will work. Do not use your real credentials.

    Create Alias credentials in the same VSTS area as the clone button and use these. Your url should look like this:

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

    Good luck.