I have an azure function in .net 7.0 isolated process shown below where I read the params passed on HTTPTrigger and send it as parameter to the stored procedure. But the CustomerKey value received will have = sign as it is encrypted. Sql extension throws run time exception when it sees = sign in the parameter.
I have been through the below document and it says we cannot have = in params list. But how do I achieve this? Is there any work around?
Parameters Optional. Zero or more parameter values passed to the command during execution as a single string. Must follow the format @param1=param1,@param2=param2. Neither the parameter name nor the parameter value can contain a comma (,) or an equals sign (=).
[Function("GetCustomers")]
public static async Task<HttpResponseData> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "customers/{CustomerKey}/{batchsize:int}")] HttpRequestData req,
ILogger log,
[SqlInput(commandText: "storedprocName", commandType: System.Data.CommandType.StoredProcedure,
parameters: "@CustomerKey={CustomerKey},@BatchSize={batchsize}", connectionStringSetting: "SqlConnectionString")]
IAsyncEnumerable<customer> customers)
{ ...}
When we run the azure function, if the URL parameter has value = it results in run time exception.
System.Private.CoreLib: Exception while executing function: Functions.GetCustomers. Microsoft.Azure.WebJobs.Extensions.Sql: Parameters must be separated by "," and parameter name and parameter value must be separated by "=", i.e. "@param1=param1,@param2=param2". To specify a null value, use null, as in "@param1=null,@param2=param2".To specify an empty string as a value, simply do not add
anything after the equals sign, as in "@param1=,@param2=param2".
To pass the parameters value which is containing
=, you can encode the value with%3D.Sample Code:
Decode the encoded parameter in stored procedure:
Sample code:
Refer GitHub issue on the same.