none
Functions App ARM Template with source control throws an error! RRS feed

  • Question

  • Hi, I picked up an ARM template from https://github.com/Azure/azure-quickstart-templates/tree/master/101-function-app-create-dynamic to set up a new functions app. I added to it a source control resource using https://github.com/Azure/azure-quickstart-templates/tree/master/201-web-app-github-deploy. I want to launch the same functions app in different regions. The final ARM template (simplified for brevity) looks like this:

    { "$schema": "http://schemas.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "appName": { "type": "string", "metadata": { "description": "The name of the function app that you wish to create." } }, "storageAccountType": { "type": "string", "defaultValue": "Standard_LRS", "allowedValues": [ "Standard_LRS", "Standard_GRS", "Standard_ZRS", "Premium_LRS" ], "metadata": { "description": "Storage Account type" } }, "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." } } }, "variables": { "functionAppName": "[parameters('appName')]", "hostingPlanName": "[parameters('appName')]", "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'azfunctions')]", "storageAccountid": "[concat(resourceGroup().id,'/providers/','Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]" }, "resources": [ { "type": "Microsoft.Storage/storageAccounts", "name": "[variables('storageAccountName')]", "apiVersion": "2015-06-15", "location": "[resourceGroup().location]", "properties": { "accountType": "[parameters('storageAccountType')]" } }, { "type": "Microsoft.Web/serverfarms", "apiVersion": "2015-04-01", "name": "[variables('hostingPlanName')]", "location": "[resourceGroup().location]", "properties": { "name": "[variables('hostingPlanName')]", "computeMode": "Dynamic", "sku": "Dynamic" } }, { "apiVersion": "2015-08-01", "type": "Microsoft.Web/sites", "name": "[variables('functionAppName')]", "location": "[resourceGroup().location]", "kind": "functionapp", "dependsOn": [ "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]", "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]" ], "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]", "siteConfig": { "appSettings": [ { "name": "AzureWebJobsDashboard", "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]" }, { "name": "AzureWebJobsStorage", "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]" }, { "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]" }, { "name": "WEBSITE_CONTENTSHARE", "value": "[toLower(variables('functionAppName'))]" }, { "name": "FUNCTIONS_EXTENSION_VERSION", "value": "~1" }, { "name": "WEBSITE_NODE_DEFAULT_VERSION", "value": "6.5.0" }, { "name": "location", "value": "[resourceGroup().location]" } ] } }, "resources": [ { "apiVersion": "2015-08-01", "name": "web", "type": "sourcecontrols", "dependsOn": [ "[resourceId('Microsoft.Web/Sites', variables('functionAppName'))]" ], "properties": { "RepoUrl": "[parameters('repoURL')]", "branch": "[parameters('branch')]", "isManualIntegration": false } } ] } ] }

    Here is PowerShell script (simplified for brevity) to try to create these functions apps in different resource groups:

    # Login to Azure first
    Login-AzureRmAccount
    
    # Select the subscription
    Get-AzureRmSubscription | select SubscriptionName
    $subscr = "mine"
    Select-AzureRmSubscription -SubscriptionName $subscr
    
    # 1. create a new resource group in west US
    New-AzureRmResourceGroup -Name WebTest4WestUS -Location "West US"
    
    # 1.5. deploy the template to the west us resource group
    New-AzureRmResourceGroupDeployment -Name WebTest4WestUSDeployment -ResourceGroupName WebTest4WestUS `
      -TemplateFile azuredeploy.json  
    
    # 2. create a new resource group in west europe
    New-AzureRmResourceGroup -Name WebTest4WestEurope -Location "West Europe"
    
    # 2.5. deploy the template to the west europe resource group
    New-AzureRmResourceGroupDeployment -Name WebTest4WestEuropeDeployment -ResourceGroupName WebTest4WestEurope `
      -TemplateFile azuredeploy.json
    
    # 3. create a new resource group in West Japan
    New-AzureRmResourceGroup -Name WebTest4WestJapan -Location "Japan West"
    
    # 3.5. deploy the template to the west japan resource group
    New-AzureRmResourceGroupDeployment -Name WebTest4WestJapanDeployment -ResourceGroupName WebTest4WestJapan `
      -TemplateFile azuredeploy.json    
    
    # 4. create a new resource group in South Brazil
    New-AzureRmResourceGroup -Name WebTest4SouthBrazil -Location "Brazil South"
    
    # 4.5. deploy the template to the south brazil resource group
    New-AzureRmResourceGroupDeployment -Name WebTest4SouthBrazilDeployment -ResourceGroupName WebTest4SouthBrazil `
      -TemplateFile azuredeploy.json  
      
    ######
    
    # Delete the resource groups
    Remove-AzureRmResourceGroup -Name WebTest4WestUS -Force
    Remove-AzureRmResourceGroup -Name WebTest4WestEurope -Force
    Remove-AzureRmResourceGroup -Name WebTest4WestJapan -Force
    Remove-AzureRmResourceGroup -Name WebTest4SouthBrazil -Force
       

    My repo URL is made up like this: https://{username}:{token}@mystuff.visualstudio.com/DefaultCollection/WebTest/_git/Functions where token is a 90-day token I got from the VS security tab.

    Trying the first one for West US worked once....but I had some problem pushing the code....it was not synchronizing the code unless I did manual synch. Anyway, I then decided to remove the RG and try again. It never worked since then....it always give the error: VSO GetRepository: cannot find repository blah blah....although I know for sure the URL is correct. If I click the link in a private browser session, it works fine.

    Sometimes it takes 10 minutes to finally throw the error! I tried different regions and it never works any more...I tried at least a dozen times. 

    Please help....any pointer is appreciated.



    • Edited by Khaled Hikmat Saturday, February 11, 2017 6:47 AM Spelling probem
    Saturday, February 11, 2017 6:38 AM

Answers

  • Wow....all I had to do is to remove the {username}:{token} from the repo URL and things seem to work quite well. So I will close this issue ...but I am not sure when I should include the {username}:{token} and when I should not.

    Thanks


    Khaled Hikmat

    • Marked as answer by Khaled Hikmat Saturday, February 11, 2017 8:38 AM
    Saturday, February 11, 2017 8:38 AM

All replies

  • Wow....all I had to do is to remove the {username}:{token} from the repo URL and things seem to work quite well. So I will close this issue ...but I am not sure when I should include the {username}:{token} and when I should not.

    Thanks


    Khaled Hikmat

    • Marked as answer by Khaled Hikmat Saturday, February 11, 2017 8:38 AM
    Saturday, February 11, 2017 8:38 AM
  • It's only needed for manual integration scenarios (isManualIntegration: true). Here, it's authenticating automatically based on your user having access to both your Azure account and VSTS account.
    Saturday, February 11, 2017 5:25 PM