如何知道 Azure 函数是否在插槽中运行 [英] How to know if an Azure function is running in a slot

查看:19
本文介绍了如何知道 Azure 函数是否在插槽中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

函数能否知道它是否在插槽中运行?

如果在暂存"中,我想阻止一个函数被执行.插槽.

<块引用>

更新

根据 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆