Skip to content

Latest commit

 

History

History

azure-ts-subscriptionid-from-resourcegroup

Azure Resource Group returning subscription ID in TypeScript

Create an Azure resource group and return the Azure subscriptionId

Deployment

  1. Login to Azure CLI (you will be prompted to do this during deployment if you forget this step)

    az login
  2. Create a new stack

    pulumi stack init dev
  3. Install dependencies

    npm install
  4. Configure the location to deploy the resources to. The Azure region to deploy to is pre-set to WestUS - but you can modify the region you would like to deploy to.

    pulumi config set azure-native:location eastus2
  5. Create that stack via pulumi up

    pulumi up -y

    Results

    Previewing update (dev)
    
    View Live: https://app.pulumi.com/myuser/azure-ts-subscriptionid-from-resourcegroup/dev/previews/0c785e89-b887-48e2-8fb3-fdd78ea9d749
    
        Type                                     Name                                            Plan       
    +   pulumi:pulumi:Stack                      azure-ts-subscriptionid-from-resourcegroup-dev  create     
    +   └─ azure-native:resources:ResourceGroup  demo-rg                                         create     
    
    Resources:
        + 2 to create
    
    Updating (dev)
    
    View Live: https://app.pulumi.com/myuser/azure-ts-subscriptionid-from-resourcegroup/dev/updates/5
    
        Type                                     Name                                            Status      
    +   pulumi:pulumi:Stack                      azure-ts-subscriptionid-from-resourcegroup-dev  created     
    +   └─ azure-native:resources:ResourceGroup  demo-rg                                         created     
    
    Outputs:
        myresourcegroup_name: "demo-rg9f01d49b"
        subscriptionid      : "[secret]"
    
    Resources:
        + 2 created
    
    Duration: 5s
  6. View the outputs created via pulumi stack output

    pulumi stack output

    Results

    Current stack outputs (2):
     OUTPUT                VALUE
     myresourcegroup_name  demo-rg9f01d49b
     subscriptionid        [secret]
  7. The outputs are secrets. To view them run the following

    pulumi stack output --show-secrets

    The Subscription ID will show up.

  8. Clean up - Destroy the Stack

    pulumi destoy -y
  9. Remove the stack

    pulumi stack rm dev