I have a .net Azure function project which includes multiple functions such as EventGridTrigger function, BlobTrigger function etc. Few trigger functions in the project needs to be enabled only for specific regions. Is it possible to enable/disable trigger functions based on regions through app settings ?
[FunctionName("CosmosDBFunction")] //enable only in US-west
public static void Run([CosmosDBTrigger()])
{}
[FunctionName("EventGridFunction")] //enable only in US-east
public static void Run([EventGridTrigger]EventGridEvent eventGridEvent)
{}
Edit:
I’m trying to disable in "isolated" Azure functions via appsettings.json within the project. The "[Disable]" and AzureWebJobs.$FunctionName.Disabled properties are not working from appsettings.json, though it is working if mentioned in azure portal.
2
Answers
You can use the
Disable
attribute, which dynamically disables specific Functions based on app settings.For example:
Each regional deployment will then set the
FUNCTION_DISABLED
setting totrue
if the Function should be disabled.One way to disable/Enable Azure functions based on regions by using PowerShell command. I could able to achieve this by using
Update-AzFunctionAppSetting
command wherein all the functions of the mentioned location will be Disabled – MSFT Docs.Subscription Level
FunctionApp Level
SAMPLE RESULTS:
Note: Replace
-AppSetting @{"AzureWebJobs.$FunctionName.Disabled" = "false"}
to true to enable it again.