You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/sql-database/includes/sql-database-create-single-database.md
+93-84Lines changed: 93 additions & 84 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ To create a resource group, SQL server, and single database in the Azure portal:
18
18
19
19
1. Sign in to the [portal](https://portal.azure.com).
20
20
1. From the Search bar, search for and select **Azure SQL**.
21
-
1.Select**Add**.
21
+
1.On the **Azure SQL** page, select**Add**.
22
22
23
23

24
24
@@ -27,7 +27,7 @@ To create a resource group, SQL server, and single database in the Azure portal:
27
27
28
28

29
29
30
-
1. On the **Basics** tab of the **Create SQL database** form, under **Project details**, drop down and select the correct Azure **Subscription** if it isn't already selected.
30
+
1. On the **Basics** tab of the **Create SQL database** form, under **Project details**, select the correct Azure **Subscription** if it isn't already selected.
31
31
1. Under **Resource group**, select **Create new**, enter *myResourceGroup*, and select **OK**.
32
32
1. Under **Database details**, for **Database name** enter *mySampleDatabase*.
33
33
1. For **Server**, select **Create new**.
@@ -62,14 +62,96 @@ To create a resource group, SQL server, and single database in the Azure portal:
For more information about firewall settings, see [Allow Azure services and resources to access this server](../sql-database-networkaccess-overview.md) and [Add a private endpoint](../../private-link/private-endpoint-overview.md).
66
+
65
67
1. On the **Additional settings** tab, in the **Data source** section, for **Use existing data**, select **Sample**.
66
68
1. Select **Review + create** at the bottom of the page.
For more information about firewall settings, see [Allow Azure services and resources to access this server](../sql-database-networkaccess-overview.md) and [Add a private endpoint](../../private-link/private-endpoint-overview.md).
74
+
# [Azure CLI](#tab/azure-cli)
75
+
76
+
You can create an Azure resource group, SQL server, and single database using the Azure command-line interface (Azure CLI). If you don't want to use the Azure Cloud Shell, [install Azure CLI](/cli/azure/install-azure-cli) on your computer.
77
+
78
+
To run the following code sample in Azure Cloud Shell, select **Try it** in the code sample title bar. When the Cloud Shell opens, select **Copy** in the code sample title bar, and paste the code sample into the Cloud Shell window. In the code, replace `<Subscription ID>` with your Azure Subscription ID, and for `$startIp` and `$endIP`, replace `0.0.0.0` with the public IP address of the computer you're using.
79
+
80
+
Follow the onscreen prompts to sign in to Azure and run the code. Make sure to record the generated server name and password so you can log in to your server and databases.
81
+
82
+
You can also use the Azure Cloud Shell from the Azure portal, by selecting the Cloud Shell icon on the top bar.
The first time you use Cloud Shell, select **Bash** in the **Welcome** dialog. Subsequent sessions will use Azure CLI in a Bash environment, or you can select **Bash** from the Cloud Shell control bar.
87
+
88
+
The following Azure CLI code creates an Azure resource group, SQL server, single database, and firewall rule for access to the server:
89
+
90
+
```azurecli-interactive
91
+
#!/bin/bash
92
+
93
+
# Sign in to Azure and set execution context (if necessary)
94
+
az login
95
+
az account set --subscription <Subscription ID>
96
+
97
+
# Set the resource group name and location for your server
98
+
resourceGroupName=myResourceGroup-$RANDOM
99
+
location=westus2
100
+
101
+
# Set an admin login and password for your database
102
+
adminlogin=azureuser
103
+
password=Azure1234567
104
+
105
+
# Set a logical server name that is unique in the system
106
+
servername=server-$RANDOM
107
+
108
+
# Set the ip address range that can access your database
109
+
startip=0.0.0.0
110
+
endip=0.0.0.0
111
+
112
+
# Create a resource group
113
+
az group create \
114
+
--name $resourceGroupName \
115
+
--location $location
116
+
117
+
# Create a logical server in the resource group
118
+
az sql server create \
119
+
--name $servername \
120
+
--resource-group $resourceGroupName \
121
+
--location $location \
122
+
--admin-user $adminlogin \
123
+
--admin-password $password
124
+
125
+
# Configure a firewall rule for the server
126
+
az sql server firewall-rule create \
127
+
--resource-group $resourceGroupName \
128
+
--server $servername \
129
+
-n AllowYourIp \
130
+
--start-ip-address $startip \
131
+
--end-ip-address $endip
132
+
133
+
# Create a gen5 2 vCore database in the server
134
+
az sql db create \
135
+
--resource-group $resourceGroupName \
136
+
--server $servername \
137
+
--name mySampleDatabase \
138
+
--sample-name AdventureWorksLT \
139
+
--edition GeneralPurpose \
140
+
--family Gen5 \
141
+
--capacity 2 \
142
+
```
143
+
144
+
The preceding code uses these Azure CLI commands:
145
+
146
+
| Command | Description |
147
+
|---|---|
148
+
|[az account set](/cli/azure/account?view=azure-cli-latest#az-account-set)| Sets a subscription to be the current active subscription. |
149
+
|[az group create](/cli/azure/group#az-group-create)| Creates a resource group in which all resources are stored. |
150
+
|[az sql server create](/cli/azure/sql/server#az-sql-server-create)| Creates a SQL Database server that hosts single databases and elastic pools. |
151
+
|[az sql server firewall-rule create](/cli/azure/sql/server/firewall-rule)| Creates a server's firewall rules. |
152
+
|[az sql db create](/cli/azure/sql/db?view=azure-cli-latest)| Creates a database. |
153
+
154
+
For more Azure SQL Database Azure CLI samples, see [Azure CLI samples](../sql-database-cli-samples.md).
73
155
74
156
# [PowerShell](#tab/azure-powershell)
75
157
@@ -79,9 +161,13 @@ You can create an Azure resource group, SQL server, and single database using Wi
79
161
80
162
To run the following code sample in the Azure Cloud Shell, select **Try it** in the code title bar. When the Cloud Shell opens, select **Copy** in the code sample title bar, and paste the code sample into the Cloud Shell window. In the code, replace `<Subscription ID>` with your Azure Subscription ID, and for `$startIp` and `$endIP`, replace `0.0.0.0` with the public IP address of the computer you're using.
81
163
82
-
Follow the onscreen prompts to sign in to Azure and run the code. Make sure to record the generated server name and password so you can log in to your server and databases.
164
+
Follow the onscreen prompts to sign in to Azure and run the code. Make sure to record the generated server name and password, so you can log in to your server and databases.
83
165
84
-
You can also use Azure Cloud Shell from the Azure portal by selecting the Cloud Shell icon on the top bar. The first time you use Cloud Shell, select **PowerShell** on the **Welcome** dialog. Subsequent sessions will use PowerShell, or you can select it from the Cloud Shell control bar.
166
+
You can also use Azure Cloud Shell from the Azure portal, by selecting the Cloud Shell icon on the top bar.
The first time you use Cloud Shell, select **PowerShell** on the **Welcome** dialog. Subsequent sessions will use PowerShell, or you can select it from the Cloud Shell control bar.
85
171
86
172
The following PowerShell code creates an Azure resource group, SQL server, single database, and firewall rule for access to the server:
87
173
@@ -143,7 +229,7 @@ The following PowerShell code creates an Azure resource group, SQL server, singl
143
229
$database
144
230
```
145
231
146
-
The preceding code uses the following PowerShell cmdlets:
232
+
The preceding code uses these PowerShell cmdlets:
147
233
148
234
| Command | Notes |
149
235
|---|---|
@@ -152,83 +238,6 @@ The preceding code uses the following PowerShell cmdlets:
152
238
|[New-AzSqlServerFirewallRule](/powershell/module/az.sql/new-azsqlserverfirewallrule)| Creates a firewall rule for a logical server. |
153
239
|[New-AzSqlDatabase](/powershell/module/az.sql/new-azsqldatabase)| Creates an Azure SQL Database single database. |
154
240
155
-
For more Azure SQL Database samples using Azure PowerShell, see [Azure PowerShell samples](sql-database-powershell-samples.md).
156
-
157
-
# [Azure CLI](#tab/azure-cli)
158
-
159
-
You can create an Azure resource group, SQL server, and single database using the Azure command-line interface (Azure CLI). If you don't want to use the Azure Cloud Shell, [install Azure CLI](/cli/azure/install-azure-cli) on your computer.
160
-
161
-
To run the following code sample in Azure Cloud Shell, select **Try it** in the code sample title bar. When the Cloud Shell opens, select **Copy** in the code sample title bar, and paste the code sample into the Cloud Shell window. In the code, replace `<Subscription ID>` with your Azure Subscription ID, and for `$startIp` and `$endIP`, replace `0.0.0.0` with the public IP address of the computer you're using.
162
-
163
-
Follow the onscreen prompts to sign in to Azure and run the code. Make sure to record the generated server name and password so you can log in to your server and databases.
164
-
165
-
You can also use the Azure Cloud Shell from the Azure portal by selecting the Cloud Shell icon on the top bar. The first time you use Cloud Shell, select **Bash** in the **Welcome** dialog. Subsequent sessions will use Azure CLI in a Bash environment, or you can select **Bash** from the Cloud Shell control bar.
166
-
167
-
The following Azure CLI code creates an Azure resource group, SQL server, single database, and firewall rule for access to the server:
168
-
169
-
```azurecli-interactive
170
-
#!/bin/bash
171
-
172
-
# Sign in to Azure and set execution context (if necessary)
173
-
az login
174
-
az account set --subscription <Subscription ID>
175
-
176
-
# Set the resource group name and location for your server
177
-
resourceGroupName=myResourceGroup-$RANDOM
178
-
location=westus2
179
-
180
-
# Set an admin login and password for your database
181
-
adminlogin=azureuser
182
-
password=Azure1234567
183
-
184
-
# Set a logical server name that is unique in the system
185
-
servername=server-$RANDOM
186
-
187
-
# Set the ip address range that can access your database
188
-
startip=0.0.0.0
189
-
endip=0.0.0.0
190
-
191
-
# Create a resource group
192
-
az group create \
193
-
--name $resourceGroupName \
194
-
--location $location
195
-
196
-
# Create a logical server in the resource group
197
-
az sql server create \
198
-
--name $servername \
199
-
--resource-group $resourceGroupName \
200
-
--location $location \
201
-
--admin-user $adminlogin \
202
-
--admin-password $password
203
-
204
-
# Configure a firewall rule for the server
205
-
az sql server firewall-rule create \
206
-
--resource-group $resourceGroupName \
207
-
--server $servername \
208
-
-n AllowYourIp \
209
-
--start-ip-address $startip \
210
-
--end-ip-address $endip
211
-
212
-
# Create a gen5 2 vCore database in the server
213
-
az sql db create \
214
-
--resource-group $resourceGroupName \
215
-
--server $servername \
216
-
--name mySampleDatabase \
217
-
--sample-name AdventureWorksLT \
218
-
--edition GeneralPurpose \
219
-
--family Gen5 \
220
-
--capacity 2 \
221
-
```
222
-
223
-
The preceding code uses these Azure CLI commands:
224
-
225
-
| Command | Description |
226
-
|---|---|
227
-
|[az account set](/cli/azure/account?view=azure-cli-latest#az-account-set)| Sets a subscription to be the current active subscription. |
228
-
|[az group create](/cli/azure/group#az-group-create)| Creates a resource group in which all resources are stored. |
229
-
|[az sql server create](/cli/azure/sql/server#az-sql-server-create)| Creates a SQL Database server that hosts single databases and elastic pools. |
230
-
|[az sql server firewall-rule create](/cli/azure/sql/server/firewall-rule)| Creates a server's firewall rules. |
231
-
|[az sql db create](/cli/azure/sql/db?view=azure-cli-latest)| Creates a database. |
241
+
For more Azure SQL Database PowerShell samples, see [Azure PowerShell samples](../sql-database-powershell-samples.md).
232
242
233
-
For more Azure SQL Database Azure CLI samples, see [Azure CLI samples](sql-database-cli-samples.md).
0 commit comments