azure-webjobs-sdk
azure-webjobs-sdk copied to clipboard
AzureWebJobs.<Function-Name>.Disabled value evaluation is case-sensitive
Please provide a succinct description of the issue.
Repro steps
Provide the steps required to reproduce the problem
-
Create a FunctionApp with at least a function in it
-
Disable the function via UI in the portal
-
The
AzureWebJobs.FunctionName.DisabledConfiguration Key is created with a value oftrue -
The function is correctly disabled
-
Change the
AzureWebJobs.FunctionName.Disabledconfiguration value toTrue(uppercase T) via Configuration blade -
The function is Enabled again!
Expected behavior
True and true should be treated in the same way, disabling the function.
Actual behavior
True is considered as a falsy value and the function is not disabled as expected.
Known workarounds
Use lowercase values: true and false
Related information
This is not a big problem while managing functions via Azure Portal as it writes the AzureWebJobs.FunctionName.Disabled config correctly (lowercase). This is really a big issue when using ARM Templates because boolean parameters are written as True/False (T/F uppercase, string representations of booleans) in the AppSettings. A workaround is to use string/int parameters in ARM templates, but it doesn't really make sense for what should be a boolean param.
Example of ARM Template that will "fail" (schema, dependsOn, etc, are omitted on purpose for brevity):
{
"parameters": {
"function_disabled": {
"type": "bool",
"defaultValue": true
}
},
"resources": [
{
"type": "Microsoft.Web/sites/config",
"apiVersion": "2016-08-01",
"name": "functionappname/appsettings",
"location": "westeurope",
"properties": {
"AzureWebJobs.MyFunction.Disabled": "[parameters('function_disabled')]"
}
}
]
}
This ARM template will produce the AzureWebJobs.MyFunction.Disabled AppSettings with a value of True or False depending on the function_disabled parameter value. If the parameter function_disabled is false, everything works as expected because False is not truthy (or at least, is not equal to true), but if function_disabled is true then you would expect MyFunction to be disabled, while it's not.
I'm searching for the sourcecode that uses the AzureWebJobs.true, checking it as a string. I would expect that the parameter is bool-parsed first, but maybe it's not.
thanks, regards
EDIT Maybe this is the "guilty" guy: https://github.com/Azure/azure-webjobs-sdk/blob/00bc34086ed262fcb3b23739d11246661bfe0a17/src/Microsoft.Azure.WebJobs.Host/ConfigurationUtility.cs#L37
This seems to be case insensitive (OrdinalIgnoreCase), so everything should work as expected....but it doesn't :(
hi, any update?
thanks a lot, regards
Hi @fume , Apologies for the delayed response, we shall look into this scenario, if this is by-design and the case sensitive can be ignored.
Hi @fume, Thank you for bringing this to notice.
Adding this issue to Traiged for update, as it is a bug. The Boolean expression needs to be parsed, which seems to be missing.
public static bool IsSettingEnabled(string settingName)
cc @brettsam / @alrod , Can you please confirm if this was an intentional change or requires update