Conceptos básicos del servicio de Blueprints de Microsoft Azure

Autor: Alexander Monakhov, Leonty Onischuk, Vitaly Gnusin - Ingenieros de DevOps , DataArt, Anna Medvedenko - Gerente de proyectos, DataArt





DevOps- Blueprints. : Blueprint, . , , , DevOps-, Azure . , , : Blueprints — , .





1. Blueprints?

Blueprints — Azure Cloud, Azure Cloud, .





Blueprints Azure .





Planos: estructura y niveles de aplicación
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