您好,我想构建后端c#,在其中我将能够查询已经配置的Azure应用程序网关的所有设置。我尝试使用Frontdoor,并使用Frontdoorclient连接到Frontdoor,并能够查询所有负载平衡器设置和其他设置。这对我有所帮助,因为Azure.management.Fluent.Frontdoor.dlll的前门有客户端,而对于azure.mamgement.network.dll,我找不到用于Azure应用程序网关的客户端。
Azure SDK不提供管理客户端来直接管理Azure应用程序网关。如果要管理它,则应使用NetworkManagementClient.ApplicationGateways
对其进行管理。有关更多详细信息,请参阅document
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