DEV Community

Cristian Sifuentes
Cristian Sifuentes

Posted on

From Portal to Script: Automating Azure Resource Provisioning with CLI

Automating Azure Resource Provisioning with CLI

From Portal to Script: Automating Azure Resource Provisioning with CLI

In today’s fast-paced cloud ecosystem, manual provisioning is quickly becoming a bottleneck. As developers, DevOps engineers, or infrastructure architects, we need repeatable, version-controlled automation. That’s where Azure CLI and scripting step in.

In this post, we’ll dive into a real-world automation example: provisioning an Azure Resource Group and Storage Account from scratch using only two Azure CLI commands inside a Bash script.


Real-World Scenario: Rapid Provisioning for Dev/Test Teams

Let’s say your development team needs on-demand storage environments to test new features or upload builds. Rather than requesting access through the portal, you create a standardized script that allows team members to spin up a Resource Group and Storage Account in seconds.


The Bash Script Breakdown

#!/bin/bash

# Step 1: Create a resource group
az group create -l eastus2 -n GrupoRecursosCLI

# Step 2: Create a basic storage account
az storage account create -n cuentacliamin001 -g GrupoRecursosCLI -l eastus2 --sku Standard_LRS
Enter fullscreen mode Exit fullscreen mode

Why This Script Matters

Feature Benefit
az group create Logical grouping of Azure resources for access control and lifecycle
az storage account create Provision Azure Blob/Table/File/Queue storage
--sku Standard_LRS Cost-efficient, locally-redundant storage ideal for non-critical environments
--location eastus2 Geographically targeted for performance and compliance

Use Case: Developer Onboarding Automation

Imagine this script is embedded in your CI/CD or onboarding system:

  1. A new developer joins the team.
  2. The script provisions their resource environment.
  3. The dev uploads, tests, or deploys safely in isolation.
  4. When done, they clean up resources (bonus: add az group delete).

Best Practices

  • Use tags on resources for cost management:
  az tag create --name env --value dev
Enter fullscreen mode Exit fullscreen mode
  • Store access credentials in Azure Key Vault.
  • Prefer RBAC over account keys for access control.
  • Log all command outputs for auditing.

Extend This Workflow

To scale this script into a real-world provisioning framework:

  • Add container creation: az storage container create
  • Upload starter files: az storage blob upload
  • Use in GitHub Actions or Azure DevOps pipelines
  • Parameterize for multiple regions and users

Conclusion

This simple script is the foundation of infrastructure as code (IaC). With just two commands, you’ve moved from the Azure portal to a programmable, repeatable cloud automation workflow.

Stay curious, script often, and transform your cloud strategy one CLI command at a time.


✍️ Written by: Cristian Sifuentes – Full-stack dev crafting scalable apps with [NET - Azure], [Angular - React], Git, SQL & extensions. Clean code, dark themes, atomic commits

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.