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:
- Go to App registrations > New registration.
- 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.
- Click Register.
Generate Client Secret:
- After registration, go to the Certificates & Secrets tab.
- Click New Client Secret, provide a description, and set an expiration date.
- Save the generated secret value (you won’t be able to view it again).
Assign Role Permissions:
- Go to Subscriptions and select the subscription where you want DevOps-Bot to operate.
- Click Access Control (IAM) > Add Role Assignment.
- 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:
- Application (Client) ID
- Directory (Tenant) ID
- Client Secret (from Step 3)
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
- Ensure the service principal has adequate permissions for the tasks you want to execute.
- Use proper tags and configuration files to ensure efficient resource management.
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 Support:
The declarative approach allows you to define the desired state of your Azure resources in a YAML configuration file. This method is best suited for automation and repeatable deployments, making it ideal for DevOps practices. The tool will parse the YAML, validate it, and execute the specified actions to provision resources as defined.
Example Use Case: You can define an entire infrastructure setup, including Virtual Machines, Virtual Networks, and Storage Accounts, in a single YAML file and deploy it with a single command.
-
Imperative CLI Commands:
The imperative approach enables you to interact with Azure resources directly via CLI commands. This is ideal for ad-hoc operations, such as creating or deleting individual resources quickly, without the need to create a configuration file. Each command corresponds to a specific Azure resource operation.
Example Use Case: You can create a Virtual Machine or a DNS Zone interactively by specifying parameters in a single command, making it suitable for quick changes or testing.
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
- Create a YAML configuration file defining the Azure resources.
- Run the `dob azure screenplay` command to execute the YAML file.
- 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
- Consistency: Ensures a repeatable and predictable resource deployment process.
- Scalability: Allows defining multiple resources in one configuration file.
- Automation: Ideal for use in CI/CD pipelines.
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
- Speed: Allows quick and direct resource creation.
- Flexibility: Perfect for ad-hoc or one-off tasks.
- Interactive: Tailored for on-the-fly operations.
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: