静态变量如何与 Azure 网站的多个实例一起使用

Aar*_*man 5 asp.net-mvc azure

运行 Azure 网站的多个实例时,静态变量如何工作?这是一个没有完全理解“什么”天蓝色网站的基本问题。取下面的简化代码。

static int MyCachedInt=10;

public ActionResult SetMyCachedInt(int a)
{
    MyCachedInt = a;
    return this.Content(MyCachedInt.ToString());
}

public ActionResult GetMyCachedInt()
{
    return this.Content(MyCachedInt.ToString());
} 
Run Code Online (Sandbox Code Playgroud)

在单个 Web 服务器或传统虚拟机上,我希望每个网站要么返回 10,要么返回最后设置的任何值。使用 Azure 是所有网站都返回相同的值还是每个实例都会单独更新?如果 Azure 扩展一个新网站,该值是 10 还是先前扩展的网站的最后一个实例?