Claude Skills Guide

Claude Code for Bicep Azure IaC Workflow Guide

Azure Infrastructure as Code (IaC) has evolved significantly with Bicep, Microsoft’s declarative language that simplifies ARM template deployment. Combined with Claude Code, you can create powerful automation workflows that handle everything from initial resource provisioning to complex multi-environment deployments. This guide walks you through building an effective Bicep-focused workflow with Claude Code.

Understanding Bicep for Azure IaC

Bicep is a domain-specific language (DSL) that provides concise syntax for deploying Azure resources. Unlike raw ARM templates, Bicep offers improved readability, type safety, and modularity. When paired with Claude Code’s intelligent assistance, you can rapidly develop, review, and maintain Azure infrastructure definitions.

The key advantages include transpilation to ARM templates, native Azure integration, and a module system that promotes reusability. Claude Code can help you navigate these features, generate boilerplate code, and catch potential issues before deployment.

Setting Up Your Environment

Before creating your Claude Code workflow, ensure your development environment is properly configured. You’ll need the Bicep CLI, Azure CLI, and appropriate credentials for authentication.

Install the Bicep CLI using Azure CLI:

az bicep install
az bicep version

Verify Azure authentication:

az login
az account show

Create a project structure for your Bicep files:

infrastructure/
├── main.bicep
├── modules/
│   ├── networking.bicep
│   ├── compute.bicep
│   └── storage.bicep
└── environments/
    ├── dev.bicepparam
    ├── staging.bicepparam
    └── prod.bicepparam

Creating the Claude Code Workflow

The foundation of your workflow is a well-structured CLAUDE.md file that defines how Claude Code should interact with your Bicep files. This file should establish clear guidelines for resource creation, parameter handling, and deployment safety.

Create a CLAUDE.md in your infrastructure repository:

# Azure Bicep Infrastructure Workflow

You are assisting with Azure Infrastructure as Code using Bicep. Follow these guidelines:

## Resource Creation
- Always use modules for reusable components
- Define parameters for environment-specific values
- Include tags for resource organization and cost tracking
- Use semantic naming conventions (e.g., rg-{environment}-{project})

## Safety Guidelines
- Require explicit approval before `az deployment group create`
- Always run `az bicep build --file` to validate syntax
- Show `az deployment group what-if` before applying changes
- Never hardcode secrets - use Key Vault references or parameters

## Code Quality
- Follow Azure naming conventions
- Include description metadata for all resources
- Use output statements for cross-module references
- Keep modules focused on single responsibility

Practical Examples

Deploying a Basic Virtual Network

Here’s how Claude Code can help you create a virtual network with subnets:

param location string = resourceGroup().location
param environment string
param vnetAddressSpace string = '10.0.0.0/16'

var namePrefix = '${environment}-hub'

resource vnet 'Microsoft.Network/virtualNetworks@2023-04-01' = {
  name: '${namePrefix}-vnet'
  location: location
  addressSpace: {
    addressPrefixes: [vnetAddressSpace]
  }
  tags: {
    Environment: environment
    ManagedBy: 'Bicep'
  }
}

resource subnetApp 'Microsoft.Network/virtualNetworks/subnets@2023-04-01' = {
  parent: vnet
  name: 'AppSubnet'
  properties: {
    addressPrefix: '10.0.1.0/24'
    privateEndpointNetworkPolicies: 'Disabled'
  }
}

resource subnetDb 'Microsoft.Network/virtualNetworks/subnets@2023-04-01' = {
  parent: vnet
  name: 'DatabaseSubnet'
  properties: {
    addressPrefix: '10.0.2.0/24'
  }
}

output vnetId string = vnet.id
output appSubnetId string = subnetApp.id

When working with Claude Code, you can describe your requirements conversationally and let it generate the appropriate Bicep syntax, then explain the structure and any Azure-specific considerations.

Creating Reusable Modules

Build modular infrastructure that scales across environments:

// modules/storage.bicep
param storageAccountName string
param location string
param skuName string = 'Standard_LRS'
param kind string = 'StorageV2'

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
  name: storageAccountName
  location: location
  sku: {
    name: skuName
  }
  kind: kind
  properties: {
    supportsHttpsTrafficOnly: true
    minimumTlsVersion: 'TLS1_2'
  }
}

output primaryEndpoint string = storageAccount.properties.primaryEndpoints.blob
output connectionString string = 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage}'

Reference this module from your main deployment:

module storage 'modules/storage.bicep' = {
  name: 'storageDeployment'
  params: {
    storageAccountName: 'mystorage${uniqueString(resourceGroup().id)}'
    location: location
    skuName: 'Standard_LRS'
  }
}

Deployment Workflow Best Practices

Validate Before Deployment

Always validate Bicep files before attempting deployment:

# Syntax validation
az bicep build --file main.bicep

# What-if analysis (preview changes)
az deployment group what-if --resource-group my-rg --template-file main.bicep

Claude Code can automate this validation step, running checks before presenting changes for approval and alerting you to potential issues like resource name conflicts or permission problems.

Environment-Specific Parameters

Use parameter files for environment-specific values:

using './main.bicep'
param environment = 'prod'
param location = 'eastus'
param aksClusterConfig = {
  nodeCount: 5
  vmSize: 'Standard_DS2_v2'
}

This separation allows the same Bicep code to deploy to development, staging, and production with appropriate configurations.

State Management

For production deployments, use remote state storage:

terraform {
  backend "azurerm" {
    resource_group_name  = "tfstate-rg"
    storage_account_name = "tfstateacc001"
    container_name       = "tfstate"
    key                  = "prod.terraform.tfstate"
  }
}

While this example shows Terraform, Bicep handles state natively through Azure Resource Manager, which tracks deployment history automatically.

Actionable Advice

Start Small: Begin with a single resource type (like storage accounts or virtual networks) and expand gradually. This lets you validate your workflow before handling complex architectures.

Implement Guardrails: Configure your Claude Code workflow to require specific checks before deployment. This includes mandatory what-if analysis, tag validation, and approval gates for production environments.

Use Azure Policy Integration: Incorporate Azure Policy compliance checks into your workflow. Claude Code can help you generate policy-compliant resource definitions and identify non-compliant resources.

Establish Naming Conventions: Define and enforce consistent naming across your infrastructure. Create a naming module that generates compliant resource names based on environment and project identifiers.

Document Your Modules: Every module should include clear parameter descriptions and output documentation. This helps team members understand what each component does without diving into implementation details.

Implement Deployment Pipelines: Combine Claude Code with CI/CD systems like Azure DevOps or GitHub Actions for automated, auditable deployments with approval workflows.

Conclusion

Integrating Claude Code with Bicep transforms Azure infrastructure management from manual template crafting to intelligent, assisted development. The workflow patterns outlined in this guide provide a foundation for scalable, maintainable IaC practices that improve team productivity and reduce deployment errors.

Start by establishing clear guidelines in your CLAUDE.md, create reusable modules for common infrastructure patterns, and always validate before deployment. With these practices in place, your team can confidently manage Azure resources at any scale.

Built by theluckystrike — More at zovo.one