简体   繁体   English

尝试在Azure上创建弹性池时发生异常

[英]Exception when trying to create an elastic pool on azure

I need to create programmaticaly an elastic pool. 我需要以编程方式创建一个弹性池。 Here is my code : 这是我的代码:

        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;

I'm using : 我正在使用 :

<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" />

I'm getting this exception on the last line: 我在最后一行收到此异常:

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()

And as you can see here, 'x-ms-request-id' is NOT a valid guid ( but RequestId property is ): 正如您在此处看到的那样,“ x-ms-request-id”不是有效的guid(但RequestId属性为): 在此处输入图片说明

Could you help me with this please ? 你能帮我这个忙吗? Is the library not yet stable for CRUD ? 库对于CRUD来说还不稳定吗?

I also can reproduce it with .net core 2.0. 我也可以使用.net core 2.0复制它。 And we also could use the way that mentioned in the another SO thread to solve it,even we don't have application Insights. 我们也可以使用另一个SO线程中提到的方法来解决它,即使我们没有应用程序见解。 More details please refer to the blog . 更多细节请参考博客 In your case we need to change dtu to equal or larger than 50 , for basic version at least 50 dtu. 在您的情况下,我们需要将dtu更改为等于或大于50 ,对于基本版本至少为50 dtu。 Following is my detail steps: 以下是我的详细步骤:

1.Create .net core 2.0 Asp.net project. 1.创建.net core 2.0 Asp.net项目。

2.Add the following code in the Startup.cs file. 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);
        }

在此处输入图片说明

3.We need to change the dtu to 50 for basic version. 3.我们需要将基本版本的dtu更改为50

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

4.Test it locally,it works correctly on my side. 4.本地测试,在我这边可以正常工作。

在此处输入图片说明

5.Check from the Azure portal 5.从Azure门户检查

在此处输入图片说明

Sometime the error messages on the API's are a bit misleading. 有时,API上的错误消息会产生误导。

Have you tried setting eDTU to 50? 您是否尝试过将eDTU设置为50?

This is the minimum eDTU's you can use for the Basic Tier you're trying to create: 这是您要尝试创建的基本层可使用的最低eDTU:

https://azure.microsoft.com/en-us/pricing/details/sql-database/ https://azure.microsoft.com/en-us/pricing/details/sql-database/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在弹性池中以编程方式创建Azure SQL数据库? - How to programmatically create an Azure SQL Database in an Elastic Pool? 获取 Azure 弹性池中的数据库数量 - Get number of databases in an Azure Elastic Pool 尝试连接到SQL Azure数据库时发生异常 - Exception when trying to connect to SQL Azure Database 使用Azure Batch Restful API创建Azure批处理池,遇到异常 - Create azure batch pool using Azure Batch Restful API, encounter exception 无法从Azure Elastic Pool删除碎片 - Can't Delete shard from Azure Elastic Pool 尝试启动Azure模拟器时出现套接字异常10048 - Socket exception 10048 when trying to start Azure emulator 尝试向 Azure 通知中心注册 Xamarin 应用程序时出现未经授权的异常 - Unauthorized Exception when trying to register Xamarin App with Azure Notification Hub 创建新的Azure Service Fabric状态服务时出现异常 - Exception when create new Azure Service Fabric Stateful Service 尝试显示创建/编辑视图时如何获取Exception消息 - how to get Exception message when trying to display create/Edit view 尝试创建文本文件时出现参数Null异常错误 - Argument Null Exception error when trying to create a Text File
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM