Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
azure web app多实例混淆_Azure_Azure Web App Service - Fatal编程技术网

azure web app多实例混淆

azure web app多实例混淆,azure,azure-web-app-service,Azure,Azure Web App Service,我有一个web应用程序,默认情况下有两个实例,从ResourceExplorer中,我可以看到有两个实例。 但是,在global.asax代码中,我有以下代码: public class LogEntity : TableEntity { public LogEntity(string partitionKey, string rowKey) { this.PartitionKey = partitionKey;

我有一个web应用程序,默认情况下有两个实例,从ResourceExplorer中,我可以看到有两个实例。 但是,在global.asax代码中,我有以下代码:

public class LogEntity : TableEntity
    {
        public LogEntity(string partitionKey, string rowKey)
        {
            this.PartitionKey = partitionKey;
            this.RowKey = rowKey;
        }
        public LogEntity() { }
        public string Submitter { get; set; }
    }

public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        Random ran = new Random();
        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);

        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
        var tableClient = storageAccount.CreateCloudTableClient();
        CloudTable table = tableClient.GetTableReference("logs");
        table.CreateIfNotExists();

        var key1 = ran.Next();
        var machineName1 = Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID");

        LogEntity log1 = new LogEntity(Environment.MachineName + ":" + machineName1 + ":" + key1.ToString(), "instance started");
        TableBatchOperation batchOperation1 = new TableBatchOperation();
        batchOperation1.Insert(log1);
        table.ExecuteBatch(batchOperation1);

    }
}
然而,从我的azure表日志中,我只能看到生成的一个日志条目,并且它总是来自同一个实例

这是否意味着当我有多个实例时,只有一个实例将调用应用程序\u start?我认为所有实例都应该在独立运行时启动应用程序。然而,我的日志似乎与我的理解相矛盾

更新


我显示了登录azure表的代码。我的期望是,由于有两个实例,我应该看到在azure表中创建的两个日志条目。但是,始终只有一个条目。

我与Microsoft支持人员进行了一些讨论,现在明白了原因

对于我的站点,我启用了ARR Affinity,启用该设置后,azure load balancer将只启用已访问的内容(作为Affinity cookie)。因此,我只看到我的代码运行一次


当我禁用关联性时,azure负载平衡器将同时启用所有实例,并且我看到我的代码在所有实例上运行

您能否共享应用程序启动时正在执行的代码?请用代码更新您的问题。谢谢!您尝试插入的实体的PartitionKey/RowKey是什么?我在你的代码中看不到这一点。如果您还可以包含
LogEntity
的代码,这也会有所帮助。partitionKey包含实例id和机器名,因此应该为不同的实例提供不同的条目
partitionKey包含实例id和机器名,因此,应该为不同的实例提供不同的条目
==>这听起来不错。我想知道您是否得到了不同的结果,或者只是我。