Azure DevOps - Configure Web or Function App Settings

Raymond Raymond event 2021-09-25 visibility 1,503
more_vert

Azure DevOps provides tasks like Azure App Service deploy and Azure Functions to deploy your built applications to Azure quickly. Those tasks provide App settings and Configuration settings inputs for you to configure your applications on Azure.

App settings

App settings are passed as environment variables to your application regardless of the type of the application. 

-KONTEXT_BUILD_NUMBER $(RELEASE.ARTIFACTS.Starlink-ASP.NET Core-CI.BUILDNUMBER)

The above example setups a variable named KONTEXT_BUILD_NUMBER. After the deployment task is completed, you will be able to find the value in App Service's Configuration Settings section. 

20210925112850-image.png

If the setting value has spaces, you need to double quote it.

Configuration settings 

Similar as App settings, you can also configure other general settings in Azure DevOps tasks for your application. For example, setup the runtime version for your PHP, Java or .NET applications.

The syntax is the same as App settings: -key value. The following screenshot set up .NET Framework version for your Azure App Service or Function applications:

20210925113240-image.png

These settings are usually configurable via Settings -> Configuration -> General settings UI directly as the following screenshot shows:

20210925113420-image.png

Use Azure App Service Settings task

Another approach is to use Azure App Service Settings task directly. This task takes JSON as input format for each settings. 

This task can be used for both web application and function application deployments to Azure. It also provides you flexibility to setup Connection Strings for your application. For example, the following task setups a Azure SQL Database connection string with name as DefaultConnection.

20210925113731-image.png

Find out available settings

Azure DevOps documentation doesn't provide the full list of available keys for the settings. To find them out, you can use Azure CLI commands.

For instance, the following command displays Azure Function App settings:

az functionapp config show -n <Function App Name> -g <Resource Group Name>

The result is a JSON document. The following is a sample output: 

*I've highlighted the setting used in the above examples:

{
  "alwaysOn": false,
  "apiDefinition": null,
  "apiManagementConfig": null,
  "appCommandLine": "",
  "appSettings": null,
  "autoHealEnabled": false,
  "autoHealRules": null,
  "autoSwapSlotName": null,
  "connectionStrings": null,
  "cors": null,
  "defaultDocuments": [
    "Default.htm",
    "Default.html",
    "Default.asp",
    "index.htm",
    "index.html",
    "iisstart.htm",
    "default.aspx",
    "index.php"
  ],
  "detailedErrorLoggingEnabled": false,
  "documentRoot": null,
  "experiments": {
    "rampUpRules": []
  },
  "ftpsState": "AllAllowed",
  "handlerMappings": null,
  "healthCheckPath": null,
  "http20Enabled": false,
  "httpLoggingEnabled": false,
  "id": "***/config/web",
  "ipSecurityRestrictions": [
    {
      "action": "Allow",
      "description": "Allow all access",
      "headers": null,
      "ipAddress": "Any",
      "name": "Allow all",
      "priority": 1,
      "subnetMask": null,
      "subnetTrafficTag": null,
      "tag": null,
      "vnetSubnetResourceId": null,
      "vnetTrafficTag": null
    }
  ],
  "javaContainer": null,
  "javaContainerVersion": null,
  "javaVersion": null,
  "kind": null,
  "limits": null,
  "linuxFxVersion": "",
  "loadBalancing": "LeastRequests",
  "localMySqlEnabled": false,
  "location": "***",
  "logsDirectorySizeLimit": 35,
  "machineKey": null,
  "managedPipelineMode": "Integrated",
  "managedServiceIdentityId": 4585,
  "minTlsVersion": "1.2",
  "name": "***-functions",
  "netFrameworkVersion": "v6.0",
  "nodeVersion": "",
  "numberOfWorkers": 1,
  "phpVersion": "5.6",
  "powerShellVersion": "",
  "preWarmedInstanceCount": 0,
  "publishingUsername": "$***-functions",
  "push": null,
  "pythonVersion": "",
  "remoteDebuggingEnabled": false,
  "remoteDebuggingVersion": "VS2019",
  "requestTracingEnabled": false,
  "requestTracingExpirationTime": null,
  "resourceGroup": "RG_PlanetX",
  "scmIpSecurityRestrictions": [
    {
      "action": "Allow",
      "description": "Allow all access",
      "headers": null,
      "ipAddress": "Any",
      "name": "Allow all",
      "priority": 1,
      "subnetMask": null,
      "subnetTrafficTag": null,
      "tag": null,
      "vnetSubnetResourceId": null,
      "vnetTrafficTag": null
    }
  ],
  "scmIpSecurityRestrictionsUseMain": false,
  "scmMinTlsVersion": "1.0",
  "scmType": "VSTSRM",
  "systemData": null,
  "tracingOptions": null,
  "type": "Microsoft.Web/sites/config",
  "use32BitWorkerProcess": false,
  "virtualApplications": [
    {
      "physicalPath": "site\\wwwroot",
      "preloadEnabled": false,
      "virtualDirectories": null,
      "virtualPath": "/"
    }
  ],
  "vnetName": "",
  "vnetPrivatePortsCount": 0,
  "vnetRouteAllEnabled": false,
  "webSocketsEnabled": false,
  "windowsFxVersion": null,
  "xManagedServiceIdentityId": null
}

Use Azure CLI task

Obviously, you could just use Azure CLI task in Azure DevOps to perform all sort of settings too. Refer to official documentation for more details Azure CLI task.

More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts