Wednesday, November 08, 2017

How to deploy with RM template the Azure Functions Connection Strings

This post explain how to deploy connection strings for our Azure Functions with an Azure Resource Manager template.


To deploy our connection strings for our Azure Functions with an Azure Resource Manager template, we have to include in the template inside properties, a property "siteConfig" where we can include a connectionStrings property with the different connection strings:

{
      "apiVersion": "2016-08-01",
      "type": "Microsoft.Web/sites",
      "name": "our-functions-app",
      "location": "[resourceGroup().location]",
      "kind": "functionapp",
      "properties": {
        "name": "[variables('functionAppName')]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('our-functionsName'))]",
        "hostingEnvironment": "",
        "clientAffinityEnabled": false,
        "siteConfig": {          
          "connectionStrings": [
            {
              "name": "SqlConnection",
              "connectionString": "[concat('Server=tcp:',reference(variables('our-dbserverName')).fullyQualifiedDomainName,',1433;Initial Catalog=',variables('our-dbName'),';Persist Security Info=False;User ID=',reference(variables('our-dbserverName')).administratorLogin,';Password=',reference(variables('our-dbserverName')).administratorLoginPassword,';MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;')]"
            },
            {
              "name": "BlobConnection",
              "connectionString": "DefaultEndpointsProtocol=https;AccountName=ourblobstorage;AccountKey=yourAccountKey;EndpointSuffix=core.windows.net"
            }
          ]
        }
      },

No comments: