So I'm aware of these two questions that seem to be asking the same thing:
How to remove the word ‘api’ from Azure functions url
How to change the base "/api" path on Azure Functions (v2)?
However, I can still not get rid of the "api" prefix in my route.
My host.json
looks like:
{
"version": "2.0",
"extensions": {
"http": {
"routePrefix": ""
}
}
}
And on my HttpTrigger I'm setting my custom route:
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "myapp")] HttpRequest request,
However, when I run the app locally the end point is coming up as:
[POST] http://localhost:7071/api/myapp
If I change my host.json
to:
{
"version": "2.0",
"extensions": {
"http": {
"routePrefix": "something"
}
}
}
My app is now running on:
[POST] http://localhost:7071/something/myapp
So it appears that giving an empty string ""
is just not working. Any ideas? (I've done all the usual stuff: clean solution, delete bin/obj folder etc.)
FYI from my function app I'm using:
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.7" />
EDIT:
I'm also referencing these packages from the function app (though I don't see how this would cause this problem):
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.1" />
EDIT 2
I've narrowed down the problem to this code that is called in Startup.cs
:
IConfiguration configuration = builder.Services.BuildServiceProvider().GetService<IConfiguration>();
IConfiguration combinedConfig = new ConfigurationBuilder()
.AddConfiguration(configuration)
.AddAzureKeyVault(kvEndpoint, kvClient, new DefaultKeyVaultSecretManager());
.Build();
builder.Services.AddSingleton(combinedConfig);
// <-- this line causes the prefix "" to revert to "/api"
It essentially is adding key vault as a configuration provider to the stack of providers all ready there. (Note it doesnt matter what .Add methods I call on configuration builder, its the registration that is causing a problem). Is there another way to write this maybe?