从 azure 查询 azure 应用程序网关设置或整个 ARM 模板
Query azure application gateway settings or whole ARM template from azure
您好,我想构建后端 C#,以便能够查询已配置的 Azure 应用程序网关的所有设置。我尝试使用 Frontdoor 并使用 Frontdoorclient 连接到 frontdoor 并能够查询所有负载均衡器设置和其他设置。这对我有帮助,因为 Azure.management.Fluent.Frontdoor.dlll 上的前门有客户端,而 azure.mamgement.network.dll 我找不到 azure 应用程序网关的客户端。
Azure SDK 不提供直接管理Azure 应用程序网关的管理客户端。如果我们要管理它,我们应该使用NetworkManagementClient.ApplicationGateways
来管理它。更多详情,请参考document
- 创建服务主体并为 sp 分配角色
az login
az account set --subscription "<your subscription id>"
# the sp will have Azure Contributor role
az ad sp create-for-rbac -n "readMetric"
- 代码
# use msal get token
var app = ConfidentialClientApplicationBuilder.Create(<sp app id>)
.WithAuthority(AzureCloudInstance.AzurePublic, "<sp tenantID>")
.WithClientSecret(<sp password>)
.Build();
string[] scopes = new string[] { "https://management.azure.com/.default" };
var result = await app.AcquireTokenForClient(scopes)
.ExecuteAsync();
TokenCredentials tokenCredentials = new TokenCredentials(result.AccessToken,"Bearer");
NetworkManagementClient networkManagementClient = new NetworkManagementClient(tokenCredentials);
ApplicationGateway appgateway =await networkManagementClient.ApplicationGateways.GetAsync("<groupName>", "<resourceName>");
// get application gateway settings:https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.management.network.models.applicationgateway?view=azure-dotnet
您好,我想构建后端 C#,以便能够查询已配置的 Azure 应用程序网关的所有设置。我尝试使用 Frontdoor 并使用 Frontdoorclient 连接到 frontdoor 并能够查询所有负载均衡器设置和其他设置。这对我有帮助,因为 Azure.management.Fluent.Frontdoor.dlll 上的前门有客户端,而 azure.mamgement.network.dll 我找不到 azure 应用程序网关的客户端。
Azure SDK 不提供直接管理Azure 应用程序网关的管理客户端。如果我们要管理它,我们应该使用NetworkManagementClient.ApplicationGateways
来管理它。更多详情,请参考document
- 创建服务主体并为 sp 分配角色
az login
az account set --subscription "<your subscription id>"
# the sp will have Azure Contributor role
az ad sp create-for-rbac -n "readMetric"
- 代码
# use msal get token
var app = ConfidentialClientApplicationBuilder.Create(<sp app id>)
.WithAuthority(AzureCloudInstance.AzurePublic, "<sp tenantID>")
.WithClientSecret(<sp password>)
.Build();
string[] scopes = new string[] { "https://management.azure.com/.default" };
var result = await app.AcquireTokenForClient(scopes)
.ExecuteAsync();
TokenCredentials tokenCredentials = new TokenCredentials(result.AccessToken,"Bearer");
NetworkManagementClient networkManagementClient = new NetworkManagementClient(tokenCredentials);
ApplicationGateway appgateway =await networkManagementClient.ApplicationGateways.GetAsync("<groupName>", "<resourceName>");
// get application gateway settings:https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.management.network.models.applicationgateway?view=azure-dotnet