问题
Can a function know if it's running in a slot?
I would like to prevent a function to be executed if in "staging" slot.
Updated
Base on the answer from Bruce (thanks again buddy), I wrote that blog post http://www.frankysnotes.com/2017/09/how-to-know-when-azure-function-is.html
回答1:
Can a function know if it's running in a slot?
Per my understanding, you could check the APPSETTING_WEBSITE_SLOT_NAME
environment variable in your code, and the value would be Production when your function is under production while the value would be the slot name when your function is under a slot as follows:
For C#, you could leverage the following code for retrieving this variable:
System.Environment.GetEnvironmentVariable("APPSETTING_WEBSITE_SLOT_NAME", EnvironmentVariableTarget.Process);
Additionally, for F# you could refer to here, for JavaScript you could refer to here.
来源:https://stackoverflow.com/questions/46085155/how-to-know-if-an-azure-function-is-running-in-a-slot