Binding a string parameter to Enum type in AzureFunction

Viewed 1545

I am trying to bind a string route parameter to Enum Type like below

public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "ValidateKey/{keyType}/{key}")]HttpRequestMessage req, KeyType keyType, string key, TraceWriter log)

The code is giving me following exception when I hit the endpoint.

Exception binding parameter 'req' -> Invalid cast from 'System.String' to 'MyCommon.KeyType'."

The model binder is not able to bind the string parameter to Enum type. In a MVC or WebAPI application, binding to Enum works fine, but it seems like the binding is not supported in AzureFunction. Is there anyway to plugin a custom ModelBinder in AzureFunction to make it work ?

1 Answers
Related