Snoopy
Snoopy

Reputation: 73

Azure functions, BlobTrigger, Connection, App settings

So I am trying to get appsetting for BlobTriggerAttribute.Connection property, and it has hierarchical style name (as I need to map it later to IConfiguration), and I am struggling with naming conventions. So as far as I know the common approach is to use __(double underscore) to separate hierarchical sections, but there is one more approach which is : and it has its own disadvantages (like environment variables names can't contain this symbol). So that's how my blob trigger parameter attribute looks like

Blob trigger attribute

That's how I build ConnectionName constant

Connection name

And that's the delimiter constant

Delimiter

Here is my settings.local.json

settings.local.json

When I am running it locally, I am getting this error

Error message

But when I am changing the delimiter to : it works... But when I am rebuilding my app it gives a warning like this one

Warning

Is that some well known issue? And what kind of approach should I use here?

(Running locally on Windows machine, <AzureFunctionsVersion>v3</AzureFunctionsVersion>)

Upvotes: 0

Views: 794

Answers (1)

Snoopy
Snoopy

Reputation: 73

So after digging into Azure Functions Webhost sources I found a place where they are resolving actual connection. Seems like they are going through IConfiguration and trying to get value by at first prefixed (using this constant) and then non prefixed key. So in this case it seems that IConfiguration separator convention should be used (which is :). The only bad thing that this separator is static readonly, so in the end you can't use that value in attribute, so it have to be hardcoded...

Upvotes: 0

Related Questions