Moving on to Terraform seems to be an easy transition after working on some ARM Templates. The Terraform configuration file is a little easier than a JSON file to read and work with. Depending on what you want to deploy you would have a section for each compute resource or back end resource, i.e. storage account, resource group or a virtual machine.
In this article I will walk through a Terraform configuration file to deploy an Azure SQL database in an Azure Resource Group along with a storage account used for setting up a threat detection policy. I am also calling a PowerShell command in the configuration file to setup the long term retention backup policy for the database.
First, setup the Terraform executable. Terraform has a good step by step guide on installing the executable here.
Initialize Terraform
After setting up the Terraform executable in a folder, the first thing to do is to initialize Terraform. At a command prompt or in a terminal window in VS Code, type in Terraform Init and hit enter. Once it is initialized you are ready to begin.
Terraform Provider section
The first section is the provider section, this is where you specify the cloud provider. For this example, I am using the Azure provider. A list of all the providers can be found here. In this section, you also specify the subscription ID and the Tenant ID.
provider "azurerm" {
version="=1.20.0"
subscription_id=""
tenant_id=""
}
Terraform Resources
The majority of the Terraform configuration file will consist of resource blocks. The resource block consists of either the parameters or variables needed to deploy that resource. Below, I will try to point out the resources I am using to deploy the SQL database. Terraform will keep this state of the resource so that it maintains that same configuration through out your development process.
Resource Group
The first resource I have in the configuration file is to deploy a resource group. In this one I am just giving it the name of the resource group along with the location.
resource "azurerm_resource_group" "test2" {
name = "RGTFDBGRL93"
location = "North Central US"
}
Storage Account
Next, I am creating a storage account. This one has a bit more detail to it. Here you can see, I am giving it a name, telling it which resource group to deploy to along with location. Since there are different types of storage accounts, I need to tell it to create a standard storage account.
resource "azurerm_storage_account" "test2sa" {
name = "satfsqldbdiag01"
resource_group_name = "${azurerm_resource_group.test2.name}"
location = "North Central US"
account_tier = "Standard"
account_replication_type = "GRS"
}
Logical SQL Server for Azure SQL Database
OK, now that some of the requirements are done. We can get into the heart of creating an Azure SQL Database. One thing about an Azure SQL Database is that it still uses a SQL Server, meaning there is a logical SQL Server instance created when deploying an Azure SQL Database.
In this next section, I point out the details of the SQL Server instance, name, resource group, location, along with the administrator login and password. This login and password would be the equivalent of the sa account and password in a SQL Server instance on premise.
With Terraform there are a few things that can’t be configured in the resource block. For this, I am adding a local-exec provisioner within the SQL Server resource group. The Provisioner section gives me a way to call PowerShell commands to do some of the configuration work I need done to the database.
resource "azurerm_sql_server" "test2" {
name = "sqldbsrvrtf01"
resource_group_name = "${azurerm_resource_group.test2.name}"
location = "North Central US"
version = "12.0"
administrator_login = "sqldbadmin"
administrator_login_password = "chang3Me!"
provisioner "local-exec" {
command = "Set-AzureRmSqlServerAuditing -State Enabled -ResourceGroupName ${azurerm_resource_group.test2.name} -ServerName 'sqldbsrvrtf01' -StorageAccountName ${azurerm_storage_account.test2sa.name}"
interpreter = ["PowerShell", "-Command"]
}
}
Server Firewall Rule
Now that the logical SQL Server is set, we can give it the firewall rules.
resource "azurerm_sql_firewall_rule" "test2" {
name = "FirewallRule1"
resource_group_name = "${azurerm_resource_group.test2.name}"
server_name = "${azurerm_sql_server.test2.name}"
start_ip_address = "10.0.17.62"
end_ip_address = "10.0.17.62"
}</code
Azure SQL Database
Now, to the SQL Database. You can see here, the resource blocks are pretty much the same, give it a name, resource group and location.
Notice, at the end of this block, I added a PowerShell command to set the long term backup retention policy for the database. This will give you the ability to set monthly or weekly backup retention plans to fit your needs.
resource "azurerm_sql_database" "test2" {
name = "sqldbtf01"
resource_group_name = "${azurerm_resource_group.test2.name}"
location = "North Central US"
server_name = "${azurerm_sql_server.test2.name}"
threat_detection_policy {
state = "Enabled"
email_addresses = ["[email protected]"]
retention_days = "30"
storage_account_access_key = "${azurerm_storage_account.test2sa.primary_access_key}"
storage_endpoint = "${azurerm_storage_account.test2sa.primary_blob_endpoint}"
use_server_default = "Enabled"
}
provisioner "local-exec" {
command = "Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName ${azurerm_resource_group.test2.name} -ServerName ${azurerm_sql_server.test2.name} -DatabaseName 'sqldbsrvrtf01' -WeeklyRetention P12W -YearlyRetention P5Y -WeekOfYear 16 "
interpreter = ["PowerShell", "-Command"]
}
}
Basically, that is all you need. I kept it pretty simple here. Ideally you may want to create some variables and maybe some modules to that the code is a little more reusable and robust. But this is a good start to understanding Terraform.
One of the unique features of Terraform is that it creates a plan, sort of like an execution plan of the resources. When you enter Terraform Plan in the command prompt, it will list out all the resources it will deploy.
When ready, enter Terraform Apply to deploy the resource(s).
That’s about it. It turns out to be a pretty simple process. Next time, I will go over deploying a SQL Server virtual machine in Azure.
Hope this helps!!!
perdere 10 kg in una settimana
See how Robot makes $1000 from $1 of investment.
Link – https://tinyurl.com/y7t5j7yc
YOU NEED FAST PROXY SERVERS ?
Check it out this Anonymous and Private Proxy Servers.
HTTP & SOCKS5 Proxy supported.
IP Authentication or Password Authentication available.
HERE: https://bit.ly/3ifZkmL
Need some more money? Robot will earn them really fast.
Link – https://tinyurl.com/y7t5j7yc
자세로 움직이는데 훨씬 더 여유가 생겨서, 새로이 활기차게 서로의 음부를 바카라 사이트 공격하기시작했다.
казино х на деньги
казино х мобильная версия россия
helpful hints гидра
отзывы surfe.be
отзывы surfe.be
how often should i take viagra how much does viagra cost? side effects from viagra pills
http://omtivacbd.org/ – best cbd oil
Even a child knows how to make money. This robot is what you need!
Link – https://tinyurl.com/y7t5j7yc
Have no money? Earn it online.
Link – https://tinyurl.com/y7t5j7yc
добротный сайт
https://sexreliz.net/lesbian/
hop over to here darknet markets
Rich people are rich because they use this robot.
Link – https://tinyurl.com/y7t5j7yc
Если вам нужно заказать винтовой конвейер в Самаре, то советую воспользоваться услугами компании «Проект плюс». Их сайт находится по адресу всеконвейеры.рф. Работают по всей России. Цены демократичные, сроки изготовления очень быстрые, качество хорошее.
Купить винтовой конвейер в Самаре можно заказав на сайте всеконвейеры.рф
Guys just made a web-page for me, look at the link:
http://onlinegamblingstar.mystrikingly.com/ Tell me your guidances. Thanks.
come perdere la pancia
Try out the best financial robot in the Internet.
Link – – https://tinyurl.com/y7t5j7yc
Magzhan Kenesbai investments into Private Equity
Magzhan Kenesbai investments into Private Equity
как выиграть в казино сол
sol casino вывод средств
Hello Bello Diapers – Spring Blooms – Size 2 (32ct)
Motormax 1:24 Scale 1956 Ford Thunderbird Convertible Red Diecast Model Car
вулкан слотс регистрация
вулкан слотс скачать
vulkan slots мобильная версия
вулкан слотс 24
Money, money! Make more money with financial robot!
Link – https://plbtc.page.link/zXbp
максимум подготовка к егэ – репетитор по английскому в спб, подготовка огэ 9
No worries if you are fired. Work online.
Link – https://tinyurl.com/y7t5j7yc
игровые бонусы от казино гранд казино
https://grand-kazino-online.host/ grand казино онлайн
http://metallor.ru
Disney Baby Lion King Adventure Musical Baby Crib Mobile by Lambs & Ivy – Blue
Little Treasure Baby Girl Bodysuits 5-pack
Howdy! can you get high on lasix lasix to get ripped
купоны гугл адвордс 2020 купить – скидка яндекс директ, купить аккаунты яндекс директ с балансом
look at here now Empire Darknet Markets
клиника кодирования от алкоголизма – 12 шагов от зависимости, анонимное лечение алкоголизма
Получите доступ к магазину гидры для моментальных покупок и закладок товаров различных видов, заблокированных в обычном интернете к hydraruzxpnew4af union.
Оригинальная гидра анион ссылка приобретение заказов на «Гидре» осуществляется на базе криптовалюты
Официальный шлюз от команды HYDRA, анонимность и самая высокая скорость загрузки гарантирована. Обход блокировки 2019 г. … Ссылка на Hydra, а также безопасный вход. Власти пытаются ограничить доступ к сайту, но мы подготовили для вас новый способ входа. hydraruzxpnew4af
Go Here deep web
a knockout post гидра сайт
Making money in the net is easier now.
Link – https://tinyurl.com/y7t5j7yc
Earn additional money without efforts and skills.
Link – https://tinyurl.com/y7t5j7yc
казино х демо игры играть бесплатно
casino x com официальный
сол казино онлайн официальный сайт
sol casino скачать приложение
вулкан слотс техподдержка
казино вулкан слотс обзор
link empire market onion
Baby Girls Shoes Infant Prewalker Toddler Girls Kid Bowknot Soft Anti-Slip Crib Cotton First Walkers Shoes 0-18 Months
PediaSure Grow & Gain Kids Nutritional Shake, with Protein, DHA, and Vitamins & Minerals, Vanilla, 8 fl oz, 24 Count
вулкан слотс техподдержка
vulcan slots зеркало
гранд казино казахстан
https://grand-kazino-online.host/ гранд казино онлайн вход
как вывести деньги с сол казино
сол com казино com отзывы
perdere peso in una settimana