如何知道 Azure 函数是否在插槽中运行 [英] How to know if an Azure function is running in a slot
问题描述
函数能否知道它是否在插槽中运行?
如果在暂存"中,我想阻止一个函数被执行.插槽.
<块引用>更新
根据 Bruce 的回答(再次感谢好友),我写了那篇博文
对于 C#,您可以利用以下代码检索此变量:
System.Environment.GetEnvironmentVariable("APPSETTING_WEBSITE_SLOT_NAME", EnvironmentVariableTarget.Process);
此外,对于 F#,您可以参考 这里,对于 JavaScript,您可以参考 这里.
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
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.
这篇关于如何知道 Azure 函数是否在插槽中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!