Azure: Deploy Custom Role to Subscription - chjgithub/Helps GitHub Wiki

  1. Uploaded template.json to blob storage

  2. For this process we are going to use PowerShell.

  3. Command used to log into Azure CLI:

    az login --use-device-code

  4. Make sure your in the right subscription where you want to deploy the custom role:

    Get-AzSubscription -Subscriptionid "[SUBSCRIPTION_ID]" | Select-AzSubscription

  5. Assign the location to a variable:

    $location = Read-Host -Prompt "Enter a location (i.e. centralus)"

    Output:

    Enter a location (i.e. centralus): eastus

  6. Assign the location to the template file to a variable:

    $templateUri = "https://[SA_NAME].blob.core.windows.net/[BUCKET_NAME]/template2.json”

  7. Issue the deployment to your subscription:

    New-AzDeployment -Location $location -TemplateUri $templateUri

    Output:

    Id                      : /subscriptions/[SUBSCRIPTION_ID]/providers/Microsoft.Resources/deployments/template2
    DeploymentName          : template2
    Location                : eastus
    ProvisioningState       : Succeeded
    Timestamp               : 1/14/2021 3:10:09 AM
    Mode                    : Incremental
    TemplateLink            : 
                              Uri            : https://[SA_NAME].blob.core.windows.net/[BUCKET_NAME]/template2.json
                              ContentVersion : 1.0.0.0
                           
    Parameters              : 
                              Name               Type                       Value     
                              =================  =========================  ==========
                              actions            Array                      [
                                "Microsoft.Compute/virtualMachines/read",
                                "Microsoft.Compute/virtualMachines/start/action",
                                "Microsoft.Compute/virtualMachines/restart/action",
                                "Microsoft.Resources/subscriptions/resourceGroups/read"
                              ]
                              notActions         Array                      []        
                              roleName           String                     Restart Virtual Machines
                              roleDescription    String                     Subscription Level Deployment of a Role Definition
                           
    Outputs                 : 
    DeploymentDebugLogLevel :