Commercial & Government Azure Function Deployment Tips, Part 3

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 and part 2, we provided background information on Azure deployment and app service plan differences. In this post, we will cover the deployment differences related to the Azure service—Commercial or Government. plan.

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

Tip #4: Provide the Correct Storage Address

For Azure Commercial, your storage endpoint will end with the suffix core.windows.net. For Azure Government, your storage endpoint will end with the suffix core.usgovcloudapi.net.

We have handled this difference by providing a storageEndPointSuffix parameter for our ARM template:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        "storageEndPointSuffix": {
        "value": "core.usgovcloudapi.net"
        },
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    }
},

This parameter is used in our Government ARM template for function storage settings:

"resources": [
{
    "name": "appsettings",
    "type": "config",
    "apiVersion": "2015-08-01",
    "dependsOn": [
    "[resourceId('Microsoft.Web/sites', parameters('appServiceName'))]"
    ],
    "properties": {
    "AzureWebJobsDashboard": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), providers('Microsoft.Storage', 'storageAccounts').ApiVersions[0]).keys[0].value,';EndpointSuffix=',parameters('storageEndPointSuffix'))]",
    "AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), providers('Microsoft.Storage', 'storageAccounts').ApiVersions[0]).keys[0].value,';EndpointSuffix=',parameters('storageEndPointSuffix'))]",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    }
}

And, in our Commercial ARM template, we also use it to define the content connection string used by the Azure to support the consumption plan:

"resources": [
{
    "name": "appsettings",
    "type": "config",
    "apiVersion": "2015-08-01",
    "dependsOn": [
    "[resourceId('Microsoft.Web/sites', parameters('appServiceName'))]"
    ],
    "properties": {
    "AzureWebJobsDashboard": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), providers('Microsoft.Storage', 'storageAccounts').ApiVersions[0]).keys[0].value,';EndpointSuffix=',parameters('storageEndPointSuffix'))]",
    "AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), providers('Microsoft.Storage', 'storageAccounts').ApiVersions[0]).keys[0].value,';EndpointSuffix=',parameters('storageEndPointSuffix'))]",
    "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), providers('Microsoft.Storage', 'storageAccounts').ApiVersions[0]).keys[0].value,';EndpointSuffix=',parameters('storageEndPointSuffix'))]",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    }
}

You can see this EndpointSuffix in use in your storage account's Access keys blade in the Azure portal:

For additional information on using parameters in your ARM template, see Parameters section of Azure Resource Manager templates.

Tip #5: Provide the Correct App Service Address

For Azure Commercial, your app service endpoint will end with the suffix AzureWebsites.net. For Azure Government, it will end with the suffix AzureWebsites.us.

We have handled this difference by providing a hostUrl parameter for our ARM template, which provides the entire URL for the function app that we are deploying:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        "hostUrl": {
        "value": "CFWebHookAppServiceDEV.azurewebsites.net"
        },
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    }
}

This parameter is used, in both our Commercial ARM template and our Government ARM template for specifying the bindings of the function app:

{
    "comments": "Webhook Function App Service Bindings (Application Settings)",
    "type": "Microsoft.Web/sites/hostNameBindings",
    "name": "[concat(parameters('appServiceName'), '/', parameters('hostUrl'))]",
    "apiVersion": "2016-08-01",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}

 

More in our "Azure Deployment Tips" series:

 


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.
1 + 16 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.