[英]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.