尝试在 azure 上创建弹性池时出现异常
Exception when trying to create an elastic pool on azure
我需要以编程方式创建弹性池。这是我的代码:
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()
正如您在此处看到的,'x-ms-request-id' 不是有效的 guid(但 RequestId 属性 是):
你能帮我解决这个问题吗? CRUD 库还不稳定吗?
我也可以用 .net core 2.0 重现它。我们也可以使用另一个 to solve it,even we don't have application Insights. More details please refer to the blog中提到的方式。在您的情况下,我们需要将 dtu 更改为等于或大于 50,对于基本版本至少 50 dtu。以下是我的详细步骤:
1.Create .net 核心 2.0 Asp.net 项目。
2.Add 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基础版需要将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 在本地,它在我这边工作正常。
5.Check 来自 Azure 门户
有时 API 上的错误消息有点误导。
您是否尝试过将 eDTU 设置为 50?
这是您尝试创建的基本层可使用的最小 eDTU:
https://azure.microsoft.com/en-us/pricing/details/sql-database/
我需要以编程方式创建弹性池。这是我的代码:
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()
正如您在此处看到的,'x-ms-request-id' 不是有效的 guid(但 RequestId 属性 是):
你能帮我解决这个问题吗? CRUD 库还不稳定吗?
我也可以用 .net core 2.0 重现它。我们也可以使用另一个
1.Create .net 核心 2.0 Asp.net 项目。
2.Add 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基础版需要将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 在本地,它在我这边工作正常。
5.Check 来自 Azure 门户
有时 API 上的错误消息有点误导。
您是否尝试过将 eDTU 设置为 50?
这是您尝试创建的基本层可使用的最小 eDTU:
https://azure.microsoft.com/en-us/pricing/details/sql-database/