0
votes

I have a class library, timer-based Azure Function that is deployed using an ARM template. Everything works fine except I would like a slightly different behavior based on the target environment. When deploying to a test environment I would like the function to be initially disabled but in production it should always be enabled. Is this possible?

My current workaround is to have an app setting that tells the function to immediately exit when set to a specific value. However, this seems like a poor solution, especially since the timer-triggered function is executed quite frequently. To solve this I manually disables the function using the following switch in the Azure portal:

enter image description here

Is there perhaps possible to specify the desired state of this switch from the ARM template?

2

2 Answers

2
votes

Seems you don't need to set to a specific value in the app settings, azure function has a built-in property.

Try to use the setting in the template snippet below to disable the function, it should work.

"siteConfig": {
                    "appSettings": [
                        {
                            "name": "AzureWebJobs.MessageQueueMonitorFunction.Disabled",
                            "value": "true"
                        }
                    ]
                }
0
votes

Expanding on Joy's answer, which worked like a charm!

For the benefit of others, the "name" property above is composed like so:

AzureWebJobs.<YouFunctionName>.Disabled

where <YouFunctionName> is specified in your template.json here:

{
    "resources": [
        "name": "<YourFunctionName>",
        "type": "functions",
         "properties": {
              "config": {
                   "bindings": [
                       {
                      ...
                        }
                    ]
                }
           }
       ]
}