Skip to content

Infrastructure as Code for ACS

Automating the deployment of Azure Communication Services using Bicep or Terraform to ensure consistent and reproducible environments.

graph TD
    Plan[Plan IaC] --> Define[Define Resources]
    Define --> Deploy[Deploy to Azure]
    Deploy --> Verify[Verify Deployment]
    Verify --> Update[Update and Redeploy]

Bicep Template Examples

The following Bicep code creates an ACS resource:

resource acsResource 'Microsoft.Communication/communicationServices@2023-04-01-preview' = {
  name: 'my-acs-resource'
  location: 'Global'
  properties: {
    dataLocation: 'UnitedStates'
  }
}

Bicep Resource Dependencies

ACS resources may depend on other resources like Log Analytics for diagnostic logging.

resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2021-06-01' = {
  name: 'my-log-analytics'
  location: 'eastus'
}

resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
  name: 'acs-diagnostics'
  scope: acsResource
  properties: {
    workspaceId: logAnalytics.id
    logs: [
      {
        category: 'SmsLogs'
        enabled: true
      }
      {
        category: 'EmailLogs'
        enabled: true
      }
    ]
  }
}

Terraform Provider Configuration

To deploy ACS with Terraform, use the azurerm provider.

resource "azurerm_communication_service" "acs" {
  name                = "my-acs-resource"
  resource_group_name = "my-rg"
  data_location       = "United States"
}

Resource Dependencies and Ordering

Terraform automatically handles dependencies between resources. However, you can explicitly define them using depends_on if necessary.

See Also

Sources