03/20/2022, 11:10 PM
Hey team. I am trying to create a ManagedCluster in Azure using Pulumi Azure native library and attach it to a pre-existing VNET subnet This is how I get the subscriptionId:
const subscriptionId = azure.core.getSubscription({});
This is the code snippet where I create my VNET:
const virtualNetwork = new`vnet-${pulumi.getStack()}-${randomNo}`, {
    addressSpace: {
        addressPrefixes: [""],
    subnets: [{
        addressPrefix: "",
        name: `snet-postgres-${pulumi.getStack()}-${randomNo}`,
        serviceEndpoints: [{
            service: "Microsoft.Sql",
        addressPrefix: "",
        name: `snet-aks-${pulumi.getStack()}-${randomNo}`,
    virtualNetworkName: `vnet-${pulumi.getStack()}-${randomNo}`,
This is the code I used for the cluster:
const managedClusterName = config.get("managedClusterName") || `aks-${randomNo}`;
const cluster = new containerservice.ManagedCluster(managedClusterName, {
    resourceName: `aks-${randomNo}`,
    agentPoolProfiles: [{
        count: 2,
        maxPods: 110,
        mode: "System",
        name: "agentpool",
        nodeLabels: {},
        osDiskSizeGB: 30,
        osType: "Linux",
        type: "VirtualMachineScaleSets",
        vmSize: "Standard_B2s",
        vnetSubnetID: `/subscriptions/${subscriptionId}/resourceGroups/rsg-${pulumi.getStack()}-${randomNo}/providers/Microsoft.Network/virtualNetworks/vnet-${pulumi.getStack()}-${randomNo}/subnets/snet-aks-${pulumi.getStack()}-${randomNo}`
    enableRBAC: true,
    kubernetesVersion: "1.23.3",
    linuxProfile: {
        adminUsername: "testuser",
        ssh: {
            publicKeys: [{
                keyData: sshKey.publicKeyOpenssh,
    nodeResourceGroup: `MC_azure-go_${managedClusterName}`,
    servicePrincipalProfile: {
        clientId: adApp.applicationId,
        secret: adSpPassword.value,
    dependsOn: [virtualNetwork]
but I keep getting the following error:
azure-native:containerservice:ManagedCluster (aks-547):
    error: Code="LinkedAuthorizationFailed" Message="The client has permission to perform action 'Microsoft.Network/virtualNetworks/subnets/join/action' on scope '/subscriptions/70340165-1840-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/rsg-dev-547/providers/Microsoft.ContainerService/managedClusters/aks-547', however the linked subscription '[object Promise]' was not found."
Quite frankly I am baffled with what I'm doing wrong here. If I try to create the cluster without
dependsOn: [virtualNetwork]
, the deployment fails. If I try to create the cluster after the VNET is created, then I get the above message complaining that the linked subscription cannot be found (???) BTW, the qualified name (resource path) of the cluster is correct, including the subscriptionId.