Forum Discussion
Can you create an SQL database table with columns via an Azure ARM Template?
Hello AlexGazz,
Yes, it is possible to create an Azure SQL database table with columns using an Azure Resource Manager (ARM) template.
Here's just an example of how you can define an Azure SQL database table with columns in an ARM template:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"databaseName": {
"type": "string",
"metadata": {
"description": "The name of the Azure SQL database."
}
}
},
"resources": [
{
"type": "Microsoft.Sql/servers/databases/tables",
"apiVersion": "2019-06-01-preview",
"name": "[concat(parameters('databaseName'), '/MyTable')]",
"properties": {
"columns": [
{
"name": "Id",
"type": "int",
"isNullable": false,
"isIdentity": true,
"isPrimaryKey": true
},
{
"name": "Name",
"type": "nvarchar(50)",
"isNullable": false
},
{
"name": "Email",
"type": "nvarchar(100)",
"isNullable": true
}
]
}
}
]
}
In the above template, you can see the "columns" property within the "properties" section. Here, you can define an array of objects, where each object represents a column in the table. You can specify the column name, data type, and other properties such as whether the column is nullable, an identity column, or a primary key.
You can also use this link:
Azure Resource Manager: Create an Azure SQL Managed Instance - Azure SQL Managed Instance | Microsoft Learn
If my answer helped you, you can click on Mark as best response.
Kindest regards
Leon Pavesic