Commercial & Government Azure Function Deployment Tips, Part 2

John E. Huschka, April 14, 2018

Target Audience:
Azure Developer
Technology:

Azure Functions — Internet cloud based custom web-accessible code.

Azure Resource Manager Templates — Files in which you can group your Azure resources for deployment.

In our series introduction, we provided important background information on Azure functions, the Azure components that support them, and Azure Resource Manager’s deployment templates. In this post, we will cover the deployment differences related to your selected app service plan.

This post is part of our blog series and demonstration code on deploying Azure Commercial and Government functions.

Tip #1: Select the Correct App Service Plan

This is a critical setting in your ARM template because it will drive other configuration differences.

Our Commercial ARM template is configured to deploy our function under a consumption plan (which provides function resources dynamically):

Whereas, our Government ARM template is configured to deploy our function under a standard app service plan (which dedicates fixed resources to the function) because the consumption plan is not available in Azure Government.

For basic information regarding the available SKUs, see App Service pricing and App Service plans.

You may also find it helpful to look at Azure portal blade on which you create a new app service because it details the plans available in your specific environment. Note, however, that this blade will not show the availability of the "Consumption" plan in the Azure Commercial portal.

Tip #2: Set Always On if Needed

Always On indicates that your function is to remain running and always available.

There are two scenarios under which the setting is not available and does not apply:

  • Functions running under “free” or “shared” app service plans, because functions running under these non-dedicated plans cannot run continuously.
  • Functions running under a “consumption” plan, because the consumption plan manages the availability of the function.

In short, it applies if you are running under an app service plan of basic and above.

If your function is triggered by HTTP request (such as a webhook), Always On can be set to false. If it is triggered by other means (such as a schedule or blob trigger), you must set it to true to ensure that your function runs.

Our Government ARM template is configured to deploy our function with Always On as false, because our webhook is trigged by an HTTP call.

{
    "comments": "Webhook Function App Service Configuration (Application Settings)",
    "type": "Microsoft.Web/sites/config",
    "name": "[concat(parameters('appServiceName'), '/web')]",
    "apiVersion": "2016-08-01",
    "location": "[resourceGroup().location]",
    "scale": null,
    "properties": {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        "alwaysOn": false,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        },
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
},

Once you have deployed, you will be able to see the setting within the app service's Application Settings, within the Azure portal:

Tip #3: Provide Azure Storage Information for the Consumption Plan

Azure always requires a storage account for your function so that it has a location in which to manage function execution. This is provided by the AzureWebJobsStorage app setting in the template.

For additional information, see Automate resource deployment for your function app in Azure Functions.

For functions deployed under a consumption plan, however, there is an additional requirement. Because Azure is going to be starting and stopping your function without a permanently allocated server, a location is needed at which Azure can maintain your function’s files. This is provided by the WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE app settings.

The WEBSITE_CONTENTAZUREFILECONNECTIONSTRING provides the standard Azure connection string for the storage account hosting the storage location. This account connection string can be seen and retrieved from the storage account's Access keys blade within the Azure portal:

For additional information, see App settings reference for Azure Functions.

The WEBSITE_CONTENTSHARE setting provides the name of a file share, within the storage account, that Azure is to use for storing function collateral. Once the function is deployed, you can see this within the account using Azure Storage Explorer:


You do not need to create this file share in advance of using it.

For additional information, see App settings reference for Azure Functions.

You can see these settings in our Commercial ARM template which deploys our function under a consumption plan:

{
    "comments": "Webhook Function App Service",
    "type": "Microsoft.Web/sites",
    "kind": "functionapp",
    "name": "[parameters('appServiceName')]",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "resources": [
        {
        "name": "appsettings",
        "type": "config",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        "properties": {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), providers('Microsoft.Storage', 'storageAccounts').ApiVersions[0]).keys[0].value,';EndpointSuffix=',parameters('storageEndPointSuffix'))]",
            "WEBSITE_CONTENTSHARE": "[toLower(concat(parameters('appServiceName'), deployment().name))]",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        }
        }
    ]
},

Note that these settings are not meaningful for service plans other than the consumption plan. In fact, the deployment will fail if these settings are provided for other plans.

In part 3, we will discuss the template differences that arise from deploying to Azure Government versus Azure Commercial.

 

 


We at Collaboration Foundry are experts in Azure, including integration with SharePoint and Office 365. If you need assistance, we can help. Contact us.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHAThis question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
6 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.