How to Create a MySQL Database Server in Azure With Bicep

In this blog post, we will show you how to create a MySQL database server in Azure using Bicep.

Bicep is an infrastructure-as-a-service tool that makes it easy to manage Azure resources. We will walk you through the steps of creating a MySQL server.

In the below Bicep template, we are creating a MySQL server using a Bicep object which is suitable in use cases like this where we can hold all the configuration inside an object and move it around if needed.

Template

To deploy the template, make sure that you create a resource group before. You also need to set a username and password for the MySQL administrator user.

param mysqlsrv object = {
  skuname: 'GP_Gen5_2' 
  location: resourceGroup().location
  tier: 'GeneralPurpose'
  capacity: 2
  servername: 'ntweeklysql10'
}

resource mysqlserver 'Microsoft.DBforMySQL/servers@2017-12-01' = {
  name: mysqlsrv.servername
  location: mysqlsrv.location
  
 sku: {
    name: mysqlsrv.skuname
    capacity: mysqlsrv.capacity
    tier: mysqlsrv.tier
     

    
 }
 properties: {
   createMode: 'Default'
   administratorLoginPassword: 'PASSWORDHERE'
   administratorLogin: 'USERHERE'
 }
}

Once you run the template it will take a few minutes for it to be deployed and for the server to be available.

In the previous Bicep posts we covered:

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.