Enabling Allow access to Azure service by Terraform


When you provision SQL server on Azure, you might want to enable "Allow access to Azure service".  However, there is no attribute on Terraform AzureRm provider. Even we can't find on the REST API spec on Azure.

However, I notice that we have a PowerShell Commandlet for this.  I read a code of it.

        /// <summary>
        /// The special IP for the beginning and ending of the firewall rule that will
        /// allow all azure services to connect to the server.
        /// </summary>
        private const string AllowAzureServicesRuleAddress = "0.0.0.0";

 

It is quite easy, we should just add the firewall rule with "0.0.0.0". 🙂 I tried.

resource "azurerm_sql_firewall_rule" "test" {

 name = "Allow All Azure Service"

 resource_group_name = "${azurerm_resource_group.test.name}" 

 server_name = "${azurerm_sql_server.test.name}"

 start_ip_address = "0.0.0.0"

 end_ip_address = "0.0.0.0"

}

Then terraform plan/apply it.

Done

Resource

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Comments (0)

Skip to main content