SQL DB - AZURE - Day20
Pre-requisites
HashiCorp Terraform is installed by default in the?Azure Cloud Shell. The Cloud shell can be run?standalone, or as an integrated command-line terminal from the Azure?portal.?
To create an Azure SQL Database with a failover group using Terraform, you will need to use the azurerm_sql_database resource and set the failover_group attribute. Here is an example of how you can do this:
resource "azurerm_resource_group" "example" {
? name? ? ?= "example-group"
? location = "West US"
}
resource "azurerm_sql_server" "example" {
? name? ? ? ? ? ? ? ? ? ? ? ? ?= "example-server"
? resource_group_name? ? ? ? ? = azurerm_resource_group.example.name
? location? ? ? ? ? ? ? ? ? ? ?= azurerm_resource_group.example.location
? version? ? ? ? ? ? ? ? ? ? ? = "12.0"
? administrator_login? ? ? ? ? = "sqladmin"
? administrator_login_password = "password"
}
resource "azurerm_sql_database" "example" {
? name? ? ? ? ? ? ? ? = "example-database"
? resource_group_name = azurerm_resource_group.example.name
? server_name? ? ? ? ?= azurerm_sql_server.example.name
? location? ? ? ? ? ? = azurerm_resource_group.example.location
? edition? ? ? ? ? ? ?= "Standard"
? collation? ? ? ? ? ?= "SQL_Latin1_General_CP1_CI_AS"
? max_size_bytes? ? ? = "1073741824"
? failover_group {
? ? name = "example-failover-group"
? }
}
This will create an Azure SQL Database with a failover group called example-failover-group. You can then add additional Azure SQL Databases to the failover group by setting the failover_group_id attribute on those databases to the ID of the azurerm_sql_database resource that defines the failover group.
领英推荐
I hope this helps! Let me know if you have any questions or need further assistance.
We post regularly on social media about the free live hands-on learning opportunities, Opensource Proof Of Concepts, Solutions Architecture Reviews, Automation live hands-on, Live career Q&A Sessions, and promotions. Do follow and support us via the following links. ??
LinkedIn?|?Twitter?|??LinkedIn Group??|?YouTube
Want to Join Every week Free Terraform Cloud Automation Handson Training?
Feel free to add me in your LinkedIn connection and send me message for more steps.
"Aiming to create 1000 leaders every year with more confidence"
Are you looking for some life confidence. Feel free to reach me out?Vijayabalan Balakrishnan?not just learning.
Principal Infra Developer | AZ Dev Ops |SRE | 5XMicrosoft | 2×AWS|ITIL | AZ CI-CD | AWS| Infra Architect| Infra Modernization
2 年#connections #cfbr