Cloud-Automation-101

Cloud Automation 101 - Introduction to Cloud Automation, Azure DevOps, Infrastructure As Code (IaC), PowerShell, Azure Resource Manager (ARM), Unit-Testing with Pester, CI/CD Pipeline with Azure DevOps and more!

View project on GitHub

Cloud Automation Declarative < >

Table of content

Introduction

TODO: tbd

Declarative vs Imperative

TODO: tbd

Snippets

Custom snippets with VSCode snippets

Vscode Extension: Azure Resource Manager Templates, open source from Sam Cogan from azure-xplat-arm-tooling

VSCode ARM Snippets

Define your own VSCode snippets by pressing CTRL + Shift + P -> Preferences: Configure User Snippets

"Azure Resource Manager Basic Template": {
    "prefix": "arm",
    "body": [
        "{",
        "    \"\\$schema\": \"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",",
        "    \"contentVersion\": \"\",",
        "	/*",
        "        PARAMETER BLOCK",
        "        ",
        "    */",
        "    \"parameters\": {  },",
        "	/*",
        "        VARIABLES BLOCK",
        "        ",
        "    */",
        "    \"variables\": {  },",
        "	/*",
        "        FUNCTIONS BLOCK",
        "        ",
        "    */",
        "    \"functions\": [  ],",
        "	/*",
        "        RESOURCES BLOCK",
        "        ",
        "    */",
        "    \"resources\": [  ],",
        "	/*",
        "        OUTPUTS BLOCK",
        "        ",
        "    */",
        "    \"outputs\": {  }",
        "}"
    ]
}

Installation AzureRm Module

Installation Guide

Install-Module -Name AzureRM -AllowClobber

Login

# Import the module into the PowerShell session
Import-Module AzureRM
# Connect to Azure with an interactive dialog for sign-in
Connect-AzureRmAccount

It is possible to the the context so you won’t need to log in every time you want to use your subscription. Enable-AzureRmContextAutosave see docs

Azure Resource Manager Template

Azure Resource Manager Template

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "",
    "parameters": {  },
    "variables": {  },
    "functions": [  ],
    "resources": [  ],
    "outputs": {  }
}

Azure Resource Manager Quick Start Templates Collection

ARM Compose

How to structure and design your ARM templates.

  • Naming Convention
  • Parameter
  • Components
  • Functions
  • Outputs

TODO: TBD

ARM Functions

ARM Functions

Example Function Add

Run the add.json ARM template to add two parameters. This demonstrate the ARM function functionality. To run the Add-ARM use:

.\deploy.ps1
# 2

Specify the parameters by using a hashmap @{ first = 1; second = 1}

.\deploy.ps1 -TemplateParameterObject = @{ first = 5; second = 6}
# 11

Try code

ARM Linked Templates

Using linked and nested templates when deploying Azure resources

TODO: TBD

ARM Nested Templates

Using linked and nested templates when deploying Azure resources

TODO: TBD

ARM Deployment Order

Define the order for deploying resources in Azure Resource Manager Templates

TODO: TBD

Azure Resource Explorer

Find more about your existing infrastructure by using the Resource Explorer

Next Cloud Automation DevOps