What types are allowed as parameters for Azure Function apps written in C# that are only callable through the admin endpoint?
I've read lots of documentation and source code and I still don't know the answer. I'm looking for definitive references and clear explanations as to what that means and why, plus examples of how to implement functions with other parameter types.
I'm wondering if the Azure team expect you to accept a string of JSON and parse it yourself into proper types, but the documentation I've found doesn't say.
Additional context
The specific function I am working on is to be called only via the admin interface so does not have any Http etc bindings.
[NoAutomaticTrigger]
[FunctionName(nameof(SomeFunctionName))]
public async Task SomeFunctionName(ParameterTypeHere someParameterName)
{
...
What can I put instead of ParameterTypeHere
?
The specific use I have (this time) is that I want to pass something like List<Guid>
or Guid[]
, I don't mind if I have to wrap it in a class or something but nothing I tried worked so I've ended up splitting a string on comma and parsing out the guids which seems like a poor solution.
Currently I've got a string parameter and am calling it with:
$ curl -v http://localhost:7071/admin/functions/SomeFunctionName \
-d '{"input": "699F3073-9BFD-4DA7-9E61-4E6564D032EC,197DA362-C281-4E0F-BB92-8759F7A5B4B4"}' \
-H "Content-Type:application/json"
Research so far
Things I've already looked at that leave me still unsure what I can use beyond string
for more complex inputs:
- Azure Functions: Generic type as input parameter
- Azure Functions error - Cannot bind parameter to type String
- Cannot bind parameter, cause the parameter type is not supported by the binding (HttpTrigger of Azure Functions)
- Can not bind ILogger in azure function v1
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-manually-run-non-http
- https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script/Binding/Manual/ManualTriggerAttributeBindingProvider.cs#L39
- ServiceBusTrigger with enqueueTimeUtc argument fails when triggered via HTTP endpoint
The parameter name is ignored, and you have to pass it in with the name "input
" regardless of the actual parameter name. Just another thing to trip over.
Even more context
If you're wondering why you'd ever want an admin-only function, this was for a one-off job to be run by someone else who has access to the admin endpoints. It appeared to be the simplest thing that could work. An HttpTrigger
would have been fine, it just appeared to violate YAGNI.