Azure-docs: So what about scripting options?

Created on 19 Jun 2019  Â·  6Comments  Â·  Source: MicrosoftDocs/azure-docs

This documentation only defines doing this in the Azure Portal and statically in the source code . The former requires you to gasp manually manage and operate your Functions deployment in a point & click fashion... Yucky beyond a proof-of-concept phase. The latter is basically only helpful during development because if you use that mechanism to turn functions on/off you'd always have to redeploy... Cumbersome and yucky. I'm including the portion under the "Functions 1.x - scripting languages" heading in this camp, because despite the term 'scripting' it is still static definition that is part of the deployment, unless there is documentation missing about running the commands that applies the 'scripting', and therefore doesn't help operators manage the functions after deployment.

I came here expecting to find something indicating how I can write a script (Azure CLI, PowerShell, other?) to automate what can be done in the portal to disable a function, and ultimately re-enable it. For example, during a deployment activity that makes a change to an underlying shared resource that the Functions use I might want to temporarily disable the Functions until the relevant deployment steps succeed. Another example would be automatically disabling Functions of lower priority while Functions of higher priority are experiencing particularly high throughput that strain a shared resource (a storage account, database, etc.)

Furthermore, if there is no facility for scripting out the disabling/enabling of Azure Functions, I'd expect that to be documented as well so that we can understand the platform limitations.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 azure-functionsvc cxp doc-enhancement triaged

Most helpful comment

Hi @ggailey777, I'd also like to know whether it's possible to script disabling and re-enabling Functions, and it's just missing from the documentation, or if it's not possible at this time!

All 6 comments

Hi @bojingo Thank you for your feedback! We have assigned this issue to the author to review further and take the right course of action.

Hi @ggailey777, I'd also like to know whether it's possible to script disabling and re-enabling Functions, and it's just missing from the documentation, or if it's not possible at this time!

Hi @bojingo and @kalvinwang, I agree that we probably need to revise this article to both focus more on v2 and also to provide Azure CLI or REST examples.

The basic idea for the version 2.x runtime is that you need to add an application setting like the following in the function app in Azure:

AzureWebJobs.<function_name>.Disabled=true

So by using the Azure CLI, it would look like this:

az functionapp config appsettings set --name <function_app> \
--resource-group <my_resource_group> \
--settings AzureWebJobs.<function_name>.Disabled=true

or by REST API, first you need a POST to get the existing settings:

POST https://management.azure.com/subscriptions/<subscription_id>/resourceGroups/<my_resource_group>/providers/Microsoft.Web/sites/<function_name>/config/appSettings/list?api-version=2015-08-01 HTTP/1.1
Host: management.azure.com
Content-Length: 0
Authorization: Bearer <access_ token>
Content-Type: application/json

Then update the returned JSON to add "AzureWebJobs.<function_name>.Disabled":"true" to the returned properties array and send it back as a PUT request, like the following:

PUT https://management.azure.com/subscriptions/<subscription_id>/resourceGroups/<my_resource_group>/providers/Microsoft.Web/sites/<function_name>/config/appSettings?api-version=2015-08-01
HTTP/1.1
Host: management.azure.com
Content-Length: 906
Authorization: Bearer <access_token>
Content-Type: application/json

{
    "properties": {
        "APPINSIGHTS_INSTRUMENTATIONKEY": "34109f9f-4387-48d8-83d6-bec23c354678",
        "AzureWebJobsStorage": "...",
        "FUNCTIONS_EXTENSION_VERSION": "~2",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "...",
        "WEBSITE_CONTENTSHARE": "...",
        "WEBSITE_NODE_DEFAULT_VERSION": "8.11.1",
        "WEBSITE_TIME_ZONE": "Pacific Standard Time",
        "AzureWebJobs.BlobTriggerCSharp1.Disabled":"true"
    }
}

Note that the PUT overwrites the existing settings, so you need to include all of the existing ones in the request.

This issue has been added to the internal backlog: 1571767

Same as @bojingo. I came here expecting that info in docs. Look forward to seeing this updated.

@bojingo, @kalvinwang, and @SogoGolf I've added an example of using the Azure CLI to set an individual function to disabled using the AzureWebJobs.<function_name>.Disabled setting. This PR is in the private repo, and should be live later on Monday am.

Please note that although the Web Apps REST APIs can be used to manage function app settings, we don't currently provide REST-based examples in Functions documentation.

please-close

Was this page helpful?
0 / 5 - 0 ratings