How to Enable/Disable Azure Function programmatically

后端 未结 5 792
南方客
南方客 2020-12-11 05:25

Is there a way to programmatically enable/disable an Azure function?

I can enable/disable a function using the portal under the \"Manage\" section, which causes a r

5条回答
  •  盖世英雄少女心
    2020-12-11 05:47

    The CLI command That is used to disable the Azure function through CLI - documented here

     az functionapp config appsettings set --name  \
        --resource-group  \
        --settings AzureWebJobs.QueueTrigger.Disabled=true
    

    I had captured fiddler while while running the above command. Azure CLI works on the Python process The python process was issuing request to

    https://management.azure.com to update appsetting.

    got a reference to the same endpoint in the below REST Endpoint : https://docs.microsoft.com/en-us/rest/api/appservice/webapps/updateapplicationsettings

    Request URI :

    PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/appsettings?api-version=2019-08-01

    Headers :

    Authorization: Bearer <> ; Content-Type: application/json; charset=utf-8

    Request Body:

    {"kind": "", "properties":JSON}

    We can hardcode the properties or get it dynamically. For disabling the function, will have to update the JSON node of Properties : Azure.WebJobs.QueueTrigger.Disabled = True

    To get properties you could use the endpoint, you could refer Web Apps - List Application Settings The Output looks up as below :

    Hope this helps :)

提交回复
热议问题