Azure Management Tool - User Guide

Manage Azure resources efficiently using declarative YAML configurations and imperative CLI commands. This guide provides a comprehensive overview of both approaches, empowering users to choose the method that suits their needs best.

User Guide: Azure Configuration with DevOps-Bot

This guide walks you through the process of configuring DevOps-Bot to work with Azure. Follow the steps below to ensure a successful configuration.

Pre-requisites

Ensure DevOps-Bot is Installed:

Before proceeding, make sure that DevOps-Bot (dobe) is installed on your instance. Refer to the DevOps-Bot Installation Guide for detailed installation instructions.

Azure Instance:

Verify that you have an Azure instance created and accessible.

Step 1: Generate Azure Credentials

Log into Azure Portal:

Go to Azure Portal. Navigate to the Azure Active Directory section.

Create a Service Principal:

  1. Go to App registrations > New registration.
  2. Provide the following details:
    • Name: Enter a descriptive name (e.g., DevOps-Bot).
    • Supported Account Types: Select an appropriate option based on your use case.
  3. Click Register.

Generate Client Secret:

  1. After registration, go to the Certificates & Secrets tab.
  2. Click New Client Secret, provide a description, and set an expiration date.
  3. Save the generated secret value (you won’t be able to view it again).

Assign Role Permissions:

  1. Go to Subscriptions and select the subscription where you want DevOps-Bot to operate.
  2. Click Access Control (IAM) > Add Role Assignment.
  3. Assign appropriate roles (e.g., Contributor) to the service principal you created.

Download Credentials:

Navigate to the Overview tab of your application registration. Save the following details:

Combine these details into a JSON file in the following format:


  {
    "clientId": "YOUR_CLIENT_ID",
    "tenantId": "YOUR_TENANT_ID",
    "clientSecret": "YOUR_CLIENT_SECRET",
    "subscriptionId": "YOUR_SUBSCRIPTION_ID"
  }
      

Step 2: Configure Azure in DevOps-Bot

Transfer the JSON File to Your Instance:

Copy the JSON file with Azure credentials to your instance where DevOps-Bot is installed.

Initialize DevOps-Bot:

Run the following command to initialize the tool and create necessary files:

dob brood --init

Configure Azure Credentials:

Use the dob azure config command to configure Azure with the JSON file:

dob azure config --file-path <path_to_json_file>

Example:

dob azure config --file-path /root/azure_credentials.json

If the credentials are valid, you’ll see the following messages:

Azure credentials saved successfully.
  Azure credentials configured successfully.

Step 3: Test Azure Configuration

Create a YAML Configuration File:

Create a file named subnet.yaml with the following content:


  resources:
    subnets:
      - name: my-subnet-2
        region: eastus
        resource_group: dev-resources
        vnet_name: my-vnet
        address_prefix: 10.0.1.0/24
        tags:
          - key: environment
            value: development
          - key: project
            value: azure-automation
      

Run the Configuration File:

Use the dob azure screenplay command to execute the configuration:

dob azure screenplay subnet.yaml

Review and Confirm:

The tool will validate and lint the YAML file. A final review of actions will be displayed. For example:


  +----+----------------+---------------------------------------------------------------------------------------------------+
  |    | Category       | Value                                                                                             |
  +====+================+===================================================================================================+
  | +  | Subnet         | Subnet 1                                                                                          |
  +----+----------------+---------------------------------------------------------------------------------------------------+
  | +  | Name           | my-subnet-2                                                                                       |
  +----+----------------+---------------------------------------------------------------------------------------------------+
  | +  | Region         | eastus                                                                                            |
  +----+----------------+---------------------------------------------------------------------------------------------------+
  | +  | Address Prefix | 10.0.1.0/24                                                                                       |
  +----+----------------+---------------------------------------------------------------------------------------------------+
  | +  | VNet Name      | my-vnet                                                                                           |
  +----+----------------+---------------------------------------------------------------------------------------------------+
  | +  | Resource Group | dev-resources                                                                                     |
  +----+----------------+---------------------------------------------------------------------------------------------------+
  | +  | Tags           | [{'key': 'environment', 'value': 'development'}, {'key': 'project', 'value': 'azure-automation'}] |
  +----+----------------+---------------------------------------------------------------------------------------------------+
      

When prompted, type Y to confirm and proceed.

Successful Execution:

The tool will create the specified resources in Azure and save the execution state:

Subnet 'my-subnet-2' created successfully with ID: /subscriptions/.......
  Execution complete. State saved to: /etc/devops-bot/state_files/<execution_file>.yml

Notes

This guide provides the necessary steps to configure and test Azure integration in DevOps-Bot. For further details, check the official DevOps-Bot Documentation.

Key Features

Declarative YAML Approach

Overview

The declarative approach uses YAML files to describe the desired state of Azure resources. This ensures consistency, repeatability, and scalability for managing cloud infrastructure.

Workflow

  1. Create a YAML configuration file defining the Azure resources.
  2. Run the `dob azure screenplay` command to execute the YAML file.
  3. The tool validates the configuration, performs linting checks, and provisions the resources as specified in the YAML file.

Example YAML Configurations

Virtual Machine (VM)


  resources:
    virtual_machines:
      - name: "my-vm"
        region: "eastus"
        size: "Standard_D2s_v3"
        image:
          publisher: "MicrosoftWindowsServer"
          offer: "WindowsServer"
          sku: "2019-Datacenter"
          version: "latest"
        resource_group: "dev-resources"
        nic_id: "/subscriptions//resourceGroups/dev-resources/providers/Microsoft.Network/networkInterfaces/my-nic"
        os_type: "Windows"
        admin_username: "azureuser"
        admin_password: "StrongP@ssw0rd"
        tags:
          - key: "environment"
            value: "production"
      

DNS Zone


  resources:
    dns_zones:
      - name: "my-dns-zone.com"
        region: "global"
        resource_group: "dev-resources"
        tags:
          - key: "environment"
            value: "production"
          - key: "project"
            value: "azure-automation"
      

Command to Execute YAML


  dob azure screenplay /path/to/configuration.yaml
      

Advantages

Imperative CLI Commands

Overview

The imperative CLI commands allow users to manage Azure resources directly using the command line. This approach is quick and efficient for one-time or ad-hoc resource management tasks.

General Syntax


  dob azure  [OPTIONS]
      

Example: To create a Virtual Machine, you would use the following command:


  dob azure create-vm \
    --name my-vm \
    --region eastus \
    --size Standard_D2s_v3 \
    --image MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest \
    --resource-group dev-resources \
    --nic-id "/subscriptions//resourceGroups/dev-resources/providers/Microsoft.Network/networkInterfaces/my-nic" \
    --os-type Windows \
    --admin-username azureuser \
    --admin-password "StrongP@ssw0rd" \
    --tags "environment=production,project=myproject"
      

Supported Commands

1. Virtual Machines (VMs)

Create a Virtual Machine

  dob azure create-vm \
    --name  \
    --region  \
    --size  \
    --image  \
    --resource-group  \
    --nic-id  \
    --os-type  \
    --admin-username  \
    --admin-password  \
    --tags "key=value,key=value"
      

2. Subnet

Create Subnet

  dob azure create-subnet \
    --vnet-name  \
    --subnet-name  \
    --resource-group  \
    --address-prefix 
      

3. Virtual Network (VNet)

Create VNet

  dob azure create-vnet \
    --name  \
    --region  \
    --resource-group  \
    --address-prefixes  \
    --tags "key=value,key=value"
      

4. DNS Zone

Create DNS Zone

  dob azure create-dns-zone \
    --name  \
    --resource-group  \
    --region  \
    --tags "key=value,key=value"
      

Advantages

Conclusion

Whether you prefer the structured approach of declarative YAML or the quick, flexible nature of imperative CLI commands, the Azure Management Tool empowers you to manage resources efficiently and effectively. Use this guide to streamline your Azure management processes.


Installation Steps PDF Reference for Azure configuration

For detailed installation steps, please refer to the PDF documentation:


Your browser does not support PDFs. Download the PDF.