Deploy Azure SQL Server, Database and Elastic pool in one go using Bicep! : Gregor Suttie

Deploy Azure SQL Server, Database and Elastic pool in one go using Bicep!
by: Gregor Suttie
blow post content copied from  Azure Greg
click here to view original post


When setting up your infrastructure in Azure, using the Azure Verified Modules can streamline the creation of any Azure Resource such as an Azure SQL Server, an Elastic Pool, and 2 demo databases. This post guides you through the code for doing just that, I leave it to you to create the parameters and fill them in 🙂

Bicep Code

//MARK: SQL Server
@description('SQL Server')
module sqlServer 'br/public:avm/res/sql/server:0.8.0' = if (deploySQLServer) {
  scope: resourceGroup("resourceGroupArray[4].name")
  name: 'sqlServer-${environmentName}'
  params: {
    name: sqlServerName
    administratorLogin: sqlAdministratorLogin
    administratorLoginPassword: keyVault.getSecret(config.kvSQLPassword)
    managedIdentities: {
      systemAssigned: false
      userAssignedResourceIds: [
        managedIdentity.id
      ]
    }
    primaryUserAssignedIdentityId: managedIdentity.id
    location: location
    tags: tags
    databases: [
      {
        name: 'demodb1'
        maxSizeBytes: 2147483648
        skuName: 'ElasticPool'
        skuTier: 'GeneralPurpose'
        zoneRedundant: false
        capacity: 0
        elasticPoolId: 'subscriptions/${subscriptionId}/resourceGroups/${resourceGroupArray[4].name}/providers/Microsoft.Sql/servers/${sqlServerName}/elasticpools/${elasticPoolName}'
      }
      {
        name: 'demodb2'
        maxSizeBytes: 2147483648
        skuName: 'ElasticPool'
        skuTier: 'GeneralPurpose'
        zoneRedundant: false
        capacity: 0
        elasticPoolId: 'subscriptions/${subscriptionId}/resourceGroups/${resourceGroupArray[4].name}/providers/Microsoft.Sql/servers/${sqlServerName}/elasticpools/${elasticPoolName}'
      }
    ]
    elasticPools: [
      {
        maxSizeBytes: 34359738368
        name: elasticPoolName
        perDatabaseSettings: {
            minCapacity: 0
            maxCapacity: 2
        }
        skuCapacity: 2
        skuName: 'GP_Gen5'
        skuTier: 'GeneralPurpose'
        zoneRedundant: false
        maintenanceConfigurationId: '/subscriptions/${subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default'
      }
    ]
  }
}

This code will now create an Azure SQL Server, an Elastic Pool and 2 demo databases within the Elastic Pool. Yes this code could be tidied up even further but the purpose it so show you how easy it can be to deploy resources using Bicep along with the Azure Verifies Modules github repository.

The post Deploy Azure SQL Server, Database and Elastic pool in one go using Bicep! appeared first on Azure Greg.


October 16, 2024 at 12:32AM
Click here for more details...

=============================
The original post is available in Azure Greg by Gregor Suttie
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Salesforce