Microsoft Azure Blueprints Service Basics

Author: Alexander Monakhov, Leonty Onischuk, Vitaly Gnusin - DevOps Engineers, DataArt, Anna Medvedenko - Project Manager, DataArt





DevOps- Blueprints. : Blueprint, . , , , DevOps-, Azure . , , : Blueprints β€” , .





1. Blueprints?

Blueprints β€” Azure Cloud, Azure Cloud, .





Blueprints Azure .





Blueprints - structure and application levels
Blueprints β€”

2. Blueprints?





, : 





  • Role Assignments.





  • Policy Assignments.





  • Azure Resource Manager templates (ARM templates).





  • Resource Groups.









ARM-, Blueprints . , , , , ARM-. Blueprint , CI/CD.





, ARM-, Blueprint ( ) ( ). .





  Blueprint ( ) ARM-.





3. Blueprint as Code

3.1  





Blueprints Azure DevOps Azure Blueprints Neil Peterson





c Blueprints : 





  • Blueprint, (. ), (assign.json).





  • (publish) Blueprint Azure Blueprints service.





  • (assignment) Blueprint β€” , Blueprint assign.json, .









3.2 Blueprint 





Blueprint JSON β€” . 





Blueprints : 









blueprint.json β€” , β€” Blueprint. Blueprint , . 





β€―assign.json Blueprint, , Blueprint Assignment (, , SKU, , , . .). . . 









3.3





β€―FileTransformβ€― XML JSON-. 









assign.json, Blueprint. location, blueprintId, gOrganizationName g_AzureRegion: 





{
    "identity": {
      "type": "SystemAssigned"
    },
    "location": "testLocation",
    "properties": {
      "blueprintId": "testBlueprintId",
      "resourceGroups": {},
      "parameters": {
        "g_Organization_Name": {
          "value": "testOrgName"
        },
        "g_AzureRegion": {
          "value": "testLocation"
        }
      }
    }
} 
      
      



YAML- , : 





variables:
  location: 'westeurope'
  properties.blueprintId: "/subscriptions/$(SubscriptionId)/providers/Microsoft.Blueprint/blueprints/AM-BP-feature-init"
  properties.parameters.g_AzureRegion.value: $(location)
  properties.parameters.g_Organization_Name.value: "Integration"
      
      



  :





- task: FileTransform@1
  inputs:
    folderPath: '$(Agent.BuildDirectory)\blueprints'
    fileType: 'json'
    targetFiles: 'assign.json'
      
      



:





- script: type "$(Agent.BuildDirectory)\blueprints\assign.json"
      
      







3.4  





Blueprint , : 





  • β€” . 





  • ARM- β€” .





  • β€” .





  • β€” .





blueprint.json





{
    "properties": {
        "description": "This will be displayed in the essentials, so make it good",
        "targetScope": "subscription",
        "parameters": { 
            "principalIds": {
                "type": "string",
                "metadata": {
                    "displayName": "Display Name for Blueprint parameter",
                    "description": "This is a blueprint parameter that any artifact can reference. We'll display these descriptions for you in the info bubble",
                    "strongType": "PrincipalId"
                }
            },
            "genericBlueprintParameter": {
                "type": "string"
            }
        },
        "resourceGroups": {
            "SingleRG": {
                "description": "An optional description for your RG artifact. FYI location and name properties can be left out and we will assume they are assignment-time parameters",
                "location": "eastus"
            }
        }
    },
    "type": "Microsoft.Blueprint/blueprints" 
}
      
      



β€―parameters: principalIdsβ€―β€―genericBlueprintParameter





. ResourceGroup blueprint.json, . 









3.5  





Blueprint . blueprint.json









"parameters": { 
    "genericBlueprintParameter": {
        "type": "string"
    }
}
      
      



.β€―





, ARM- (defaultValue, allowedValue . .). , :





"properties": {
    "genericBlueprintParameter": "[parameters('principalIds')]",
}
      
      



:





${{ parameters.genericBlueprintParameter }}
      
      







3.6 Resource Group 





Resource Group blueprint.json :





  • : "location": "eastus".





  • ResourceGroup: SingleRG.





, (assignment). 





"name": "myRgName" SingleRG ( ).









3.7  





:





  1. Kind, , : 





    a. template, 





    b. roleAssignment, 





    c. policyAssignment.





  2. Type, :β€―Microsoft.Blueprint/blueprints/artifacts. 





  3. Properties β€” , . 









    a. dependsOn . β€―.β€― 





    b. resourceGroup , . , , blueprint.json.  





: Policy Assignment, Role Assignment, Template.β€―









3.8 Blueprints  





Blueprints : 





  • powershell ( Az.Blueprint, . );





  • , Neil Peterson ( . , ).





3.8.1. Blueprint





steps:
- task: nepeters.azure-blueprints.CreateBlueprint.CreateBlueprint@1
  displayName: 'Create Azure Blueprint'
  inputs:
    azureSubscription: 'nepeters-subscription'
    BlueprintName: 'blueprints-demo'
    BlueprintPath: ./create
    IncludeSubFolders: true
    PublishBlueprint: true
    ChangeNote: 'Added new artifacts.'
      
      



β€―Azure -> Blueprints -> Blueprint definitions.β€―





3.8.2. Blueprint





steps:
- task: nepeters.azure-blueprints.AssignBlueprint.AssignBlueprint@1
  displayName: 'Assign Azure Blueprint'
  inputs:
    azureSubscription: 'nepeters-internal'
    AssignmentName: 'prod-test-one'
    BlueprintName: 'prod-test-one'
    ParametersFile: 'assign/assign-blueprint.json'
    AlternateSubscription: true
    SubscriptionID: '00000000-0000-0000-0000-000000000000'
    Wait: true
    StopOnFailure: true
      
      



β€―Azure -> Blueprints -> Assigned blueprints. Blueprint. 













, Blueprints ARM-, . β€” . Azure, ,   .








All Articles