Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.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
C# 尝试在azure上创建弹性池时出现异常_C#_Azure_Azure Sql Database_Azure Sdk .net - Fatal编程技术网

C# 尝试在azure上创建弹性池时出现异常

C# 尝试在azure上创建弹性池时出现异常,c#,azure,azure-sql-database,azure-sdk-.net,C#,Azure,Azure Sql Database,Azure Sdk .net,我需要创建一个弹性池。这是我的密码: var credentials = new Microsoft.Rest.TokenCredentials(await GetToken()); var sqlclient = new Microsoft.Azure.Management.Sql.SqlManagementClient(credentials) { SubscriptionId = subscriptionId }; var sqlServ

我需要创建一个弹性池。这是我的密码:

        var credentials = new Microsoft.Rest.TokenCredentials(await GetToken());

        var sqlclient = new Microsoft.Azure.Management.Sql.SqlManagementClient(credentials) { SubscriptionId = subscriptionId };

        var sqlServer = (await sqlclient.Servers.GetWithHttpMessagesAsync("MyApp-com","myApp-com")).Body;

        var azurePool = (await sqlclient.ElasticPools.CreateOrUpdateWithHttpMessagesAsync("MyApp-com",sqlServer.Name,"poolname", new Microsoft.Azure.Management.Sql.Models.ElasticPool(sqlServer.Location,  edition:"Basic",dtu:5))).Body;
我正在使用:

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Resources" Version="2.20.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.6.0-preview" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.10" />

我在最后一行得到了这个例外:

Microsoft.Rest.Azure.CloudException occurred
  HResult=0x80131500
  Message=Invalid value for header 'x-ms-request-id'. The header must contain a single valid GUID.
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at Microsoft.Azure.Management.Sql.ElasticPoolsOperations.<BeginCreateOrUpdateWithHttpMessagesAsync>d__15.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.Sql.ElasticPoolsOperations.<CreateOrUpdateWithHttpMessagesAsync>d__7.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
发生Microsoft.Rest.Azure.CloudException

HResult=0x80131500
消息=标头“x-ms-request-id”的值无效。标头必须包含一个有效的GUID。
来源=
堆栈跟踪:
在Microsoft.Azure.Management.Sql.ElasticPoolsOperations.d_u15.MoveNext()上
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在Microsoft.Azure.Management.Sql.ElasticPoolsOperations.d_u7.MoveNext()上
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()中
正如您在这里看到的,“x-ms-request-id”不是有效的guid(但RequestId属性是):


你能帮我做这个吗?库对于CRUD还不稳定吗?

我也可以用.net core 2.0复制它。我们也可以使用另一篇文章中提到的方法来解决它,即使我们没有应用程序洞察力。更多详情请参阅。在您的情况下,我们需要将dtu更改为等于或大于50,对于基本版本,至少50dtu。以下是我的详细步骤:

1.创建.net core 2.0 Asp.net项目

2.在Startup.cs文件中添加以下代码

 private void DisableCorrelationIdHeaders(IServiceCollection services)
        {
            var module = services.FirstOrDefault(t => t.ImplementationFactory?.GetType() == typeof(Func<IServiceProvider, DependencyTrackingTelemetryModule>));
            if (module != null)
            {
                services.Remove(module);
                services.AddSingleton<ITelemetryModule>(provider => new DependencyTrackingTelemetryModule { SetComponentCorrelationHttpHeaders = false });
            }
        }

 public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddApplicationInsightsTelemetry();
            DisableCorrelationIdHeaders(services);
        }
4.在本地进行测试,在我这边可以正常工作

5.从Azure门户进行检查


有时API上的错误消息有点误导

你试过将eDTU设置为50吗

这是您尝试创建的基本层可以使用的最小eDTU:


复制?谢谢你,先生,我已经看到了这个问题,但是因为我没有应用权限,我告诉自己这可能是其他原因,我会在这个问题中添加一条评论,指出即使你没有AppInsight,它也可能导致这个问题。我在回答中也提到了这一点。你也可以对此发表评论。
var azurePool = (await sqlclient.ElasticPools.CreateOrUpdateWithHttpMessagesAsync("MyApp-com",sqlServer.Name,"poolname", new Microsoft.Azure.Management.Sql.Models.ElasticPool(sqlServer.Location,  edition:"Basic",dtu:50))).Body;  //at least 50 for basic version