0

Using Terraform, how do I set the Azure SQL Database (and Azure Elastic Pool) LicenseType property to enable Azure Hybrid Use Benefit (aka AHUB, aka AHB)?

Here's an example using Powershell:

# Azure SQL Database:
Set-AzSqlDatabase -DatabaseName $sqlDb.DatabaseName -ResourceGroupName $sqlDb.ResourceGroupName -ServerName $sqlDb.ServerName -LicenseType "BasePrice"

# Azure SQL Database Elastic Pool:
Set-AzSqlElasticPool -ElasticPoolName $elasticPool.elasticPoolName -ResourceGroupName $elasticPool.ResourceGroupName -ServerName $elasticPool.ServerName -LicenseType "BasePrice"

The property is easily set using Az CLI too.

This is a very important property (from a cost perspective) and I cannot find mention of it anywhere in the context of Terraform.

Thanks!

John Delisle
  • 83
  • 1
  • 9

3 Answers3

1

From Terraform documentation

license_type - (Optional) Specifies the license type applied to this database. Possible values are LicenseIncluded and BasePrice.

Here is the link https://www.terraform.io/docs/providers/azurerm/r/mssql_elasticpool.html#license_type

Alexey Auslender
  • 402
  • 5
  • 18
  • Thanks @alexey that helps for Azure SQL Database Elastic Pools, however, it doesn't address Azure SQL Databases that are not associated with Elastic Pools. Any idea how it's done on a singleton database outside of a pool? – John Delisle Jun 12 '20 at 19:08
  • Oh! Found something very promising: https://www.terraform.io/docs/providers/azurerm/r/mssql_database.html – John Delisle Jun 12 '20 at 19:15
0

Why does it seem LicenseIncluded = the "Save Money" box being unchecked. I would have thought LicenseIncluded would have add the box checked and BasePrice would be unchecked, but in practice it is the opposite.

Josh Johanning
  • 840
  • 9
  • 16
  • I guess the logic is `BasePrice` - only pay for infra (since you already have licenses somewhere else), and `LicenseIncluded` - also pay licensing fees, because you want licenses included with this offering. – Aurimas Stands with Ukraine Aug 04 '22 at 11:42
0

Hashicorp's site doesn't make this setting clear. The setting description is present, but the expanded description of the possible values is not. Combining Hashicorp's site with Microsoft's, we get:

license_type - (Optional) Specifies the license type applied to this database. Possible values are:

  • 'LicenseIncluded' if you need a license
  • 'BasePrice' if you have a license and are eligible for the Azure Hybrid Benefit

Sources: