How do I configure an Azure SQL Database?
This tutorial demonstrates how to configure an Azure SQL Database. The process includes defining and setting up various Azure resources such as the resource group, SQL server, and the database itself.
Below is an example of how to write these configurations:
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
// Create a resource group
const example = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "WestEurope",
});
// Create the SQL Server
const exampleSqlServer = new azure.sql.SqlServer("example", {
name: "example-sqlserver",
resourceGroupName: example.name,
location: example.location,
version: "12.0",
administratorLogin: "sqladmin",
administratorLoginPassword: "P@ssw0rd12345",
});
// Create the SQL Database
const exampleDatabase = new azure.sql.Database("example", {
name: "example-sqldb",
resourceGroupName: example.name,
location: example.location,
serverName: exampleSqlServer.name,
edition: "Basic",
});
export const sqlServerFqdn = exampleSqlServer.fullyQualifiedDomainName;
export const sqlDatabaseName = exampleDatabase.name;
In the provided code:
- The Azure Provider
azurerm
is configured to interact with Azure resources. - A resource group is created to logically hold all the resources.
- An Azure SQL Server is defined with administrative credentials.
- The SQL Database is established on the created server and is set to use the “Basic” edition.
- The fully qualified domain name for the SQL Server and the database name are exported for reference.
This completes the configuration. The resources can now be managed as code, ensuring that any changes can be version controlled and easily deployed or reproduced.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.