【发布时间】:2018-04-02 16:46:03
【问题描述】:
我正在尝试使用 Azure 管理 API 创建 Kubernetes 集群。
var credentials = SdkContext.AzureCredentialsFactory
.FromFile(Environment.GetEnvironmentVariable("AZURE_AUTH_LOCATION"));
var azure = Azure
.Configure()
.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
.Authenticate(credentials)
.WithDefaultSubscription();
var kubernetesCluster = azure.KubernetesClusters.Define("aks").WithRegion(Region.EuropeWest)
.WithNewResourceGroup("aksResourceGroup").WithLatestVersion().WithRootUsername("aksUsername")
.WithSshKey(sshPublicKey).WithServicePrincipalClientId("clientId")
.WithServicePrincipalSecret("secret").DefineAgentPool("ap").WithVirtualMachineCount(1)
.WithVirtualMachineSize(ContainerServiceVirtualMachineSizeTypes.StandardA0).Attach()
.WithDnsPrefix("dns-aks").Create();
在最后一行中,抛出 CloudException 并显示消息:找不到订阅 []。
即使抛出异常,也会创建资源组但它是空的。
我已经使用带有该服务主体的 Azure CLI 登录并且我已经运行了
az account list
回复如下:
[
{
"cloudName": "AzureCloud",
"id": "SUBSCRIPTION ID FROM EXCEPTION ABOVE",
"isDefault": true,
"name": "Pay-As-You-Go",
"state": "Enabled",
"tenantId": "xxx",
"user": {
"name": "xxxx",
"type": "servicePrincipal"
}
}
]
应用注册存在于 Azure Active Directory > 应用注册 > 所有应用中。我什至授予了所有可能的 API 的权限。
为了收到异常消息,我做错了什么吗?
【问题讨论】:
标签: azure kubernetes azure-container-service azure-management