问题
How can I design my Azure Function hosting for flexible test/production queue isolation?
I am planning to write 6 precompiled Azure Functions in C# packaged as single DLL and have yet to to decide if I will use WebJobSdk function annotation or multiple .json config files. My 6 Azure functions will only have input bindings and all will be triggered via storage queues.
I dislike the idea of hardcoding queue names in source code as method attribute strings but I understand that INameResolver provides for naming indirection.
Is this the standard solution for test/production storage queue binding isolation or can some other form of higher level Azure environment declaration achieve the same with zero code?
回答1:
The approach you've mentioned, where you rely on the INameResolver
functionality to set those queue names based on the environment would definitely work and give you a more flexibility than if you had those queue names defined as literals in your pre-compiled assemblies. This is particularly important if the teams maintaining the environment and writing the code are different.
It's worth noting that, although the approach above alone would work, our recommendation, for better isolation, and to avoid other potential issues, would be to use completely different storage accounts when developing/testing and when running your production workloads.
You can still leverage the INameResolver
behavior for added flexibility in this case.
来源:https://stackoverflow.com/questions/44901165/azure-function-flexible-test-and-production-queue-names