【发布时间】:2019-07-29 12:37:07
【问题描述】:
我正在尝试使用 C# 中的 Azure Fluent .NET SDK 在应用服务 (WebApp) 上配置 TLS 版本。
我使用以下代码通过 LINQPad 获取 WebApp 信息:
// Nuget : Install-Package Microsoft.Azure.Management.AppService.Fluent -Version 1.24.0
// using Microsoft.Azure.Management.AppService.Fluent;
// using Microsoft.Azure.Management.AppService.Fluent.Models;
// using Microsoft.Azure.Management.ResourceManager.Fluent;
// Using a Service Principal created on my Azure Subscription
var clientId = "<service_principal_clientid_with_readaccess>";
var tenantId = "<my_azuread_tenantid>";
var credentials = SdkContext
.AzureCredentialsFactory
.FromServicePrincipal(clientId,
Util.GetPassword("azure-cli-secret"), // LINQPad helper, replace if needed
tenantId,
AzureEnvironment.AzureGlobalCloud);
// Get one web app with TLS 1.2 configured
var webApp = AppServiceManager
.Authenticate(credentials, "<azure_subscription_id>")
.WebApps
.GetById("<webapp_resource_id>");
// Dump object returned, LINQPad helper method
webApp.Dump();
当转储对象模型返回时,我在任何地方都找不到返回的 TLS 信息。应该是可用的,因为它是由 REST API 返回的。
分析
您可以使用https://resources.azure.com 或直接在此端点上查看信息:
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{appServiceName}/config?api-version=2018-02-01
这将为您提供以下输出(此处缩短了属性列表):
{
"value": [
{
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{appServiceName}/config/web",
"name": "{appServiceName}",
"type": "Microsoft.Web/sites/config",
"location": "West Europe",
"properties": {
"http20Enabled": false,
"minTlsVersion": "1.2",
"ftpsState": "AllAllowed",
"reservedInstanceCount": 0,
"preWarmedInstanceCount": null,
"healthCheckPath": null
}
}
],
"nextLink": null,
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{appServiceName}/config"
}
然后我查看了此处提供的 SDK 代码源:https://github.com/Azure/azure-libraries-for-net。我发现 TLS 版本应该在 SiteConfig 对象中可用。此 SiteConfig 似乎位于 Inner 属性内。
查看我们使用 LINQPad 获得的对象转储时,我们可以看到 SiteConfig 对象未填充:
在调试此代码时,使用断点,我们可以看到信息似乎在内部可用,但未映射到 Inner 属性内公开可用的 SiteConfig 属性。
我们看到非公共成员 _siteConfig 填充的调试会话屏幕截图:
这是一个错误还是我错过了什么?
有什么想法吗?
【问题讨论】:
标签: azure azure-web-app-service azure-sdk-.net azure-fluent-api