Skip to content

Commit 35b31a7

Browse files
authored
Merge pull request #47381 from MicrosoftDocs/NEW-develop-azure-sql-database-2
New develop azure sql database credential
2 parents 83c39ff + 6d3a28e commit 35b31a7

20 files changed

+582
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn-wwl.develop-azure-sql-database.introduction
3+
title: Introduction
4+
metadata:
5+
title: Introduction
6+
description: "Introduction"
7+
ms.date: 9/27/2024
8+
author: jupadrao
9+
ms.author: jupadrao
10+
ms.topic: unit
11+
durationInMinutes: 3
12+
content: |
13+
[!include[](includes/1-introduction.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn-wwl.develop-azure-sql-database.create-configure-sql-database
3+
title: Create and configure an Azure SQL Database
4+
metadata:
5+
title: Create and configure an Azure SQL Database
6+
description: "Learn how to create and configure an Azure SQL Database."
7+
ms.date: 9/27/2024
8+
author: jupadrao
9+
ms.author: jupadrao
10+
ms.topic: unit
11+
durationInMinutes: 7
12+
content: |
13+
[!include[](includes/2-create-configure-sql-database.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn-wwl.develop-azure-sql-database.use-sql-db-projects
3+
title: Use SQL Database Projects
4+
metadata:
5+
title: Use SQL Database Projects
6+
description: "Learn how to use SQL Database Projects."
7+
ms.date: 9/27/2024
8+
author: jupadrao
9+
ms.author: jupadrao
10+
ms.topic: unit
11+
durationInMinutes: 7
12+
content: |
13+
[!include[](includes/3-use-sql-db-projects.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn-wwl.develop-azure-sql-database.build-deploy-github-actions
3+
title: Build and deploy database projects in GitHub Actions and Azure DevOps
4+
metadata:
5+
title: Build and deploy database projects in GitHub Actions and Azure DevOps
6+
description: "Learn how to build and deploy database projects in GitHub Actions and Azure DevOps."
7+
ms.date: 9/27/2024
8+
author: jupadrao
9+
ms.author: jupadrao
10+
ms.topic: unit
11+
durationInMinutes: 8
12+
content: |
13+
[!include[](includes/4-build-deploy-github-actions.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn-wwl.develop-azure-sql-database.secure-monitor-automation
3+
title: Secure and monitor Continuous Integration and Continuous Deployment (CI/CD)
4+
metadata:
5+
title: Secure and monitor Continuous Integration and Continuous Deployment (CI/CD)
6+
description: "Learn how to secure and monitor Continuous Integration and Continuous Deployment (CI/CD)."
7+
ms.date: 9/27/2024
8+
author: jupadrao
9+
ms.author: jupadrao
10+
ms.topic: unit
11+
durationInMinutes: 5
12+
content: |
13+
[!include[](includes/5-secure-monitor-automation.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn-wwl.develop-azure-sql-database.exercise-deploy-azure-sql-database-project
3+
title: 'Exercise: Configure and deploy CI/CD pipelines for Azure SQL Database projects'
4+
metadata:
5+
title: 'Exercise: Configure and deploy CI/CD pipelines for Azure SQL Database projects'
6+
description: "Learn how to configure and deploy CI/CD pipelines for Azure SQL Database projects."
7+
ms.date: 9/27/2024
8+
author: jupadrao
9+
ms.author: jupadrao
10+
ms.topic: unit
11+
durationInMinutes: 30
12+
content: |
13+
[!include[](includes/6-exercise-deploy-azure-sql-database-project.md)]
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn-wwl.develop-azure-sql-database.knowledge-check
3+
title: Knowledge check
4+
metadata:
5+
title: Knowledge check
6+
description: "Knowledge check"
7+
ms.date: 9/27/2024
8+
author: jupadrao
9+
ms.author: jupadrao
10+
ms.topic: unit
11+
durationInMinutes: 8
12+
quiz:
13+
questions:
14+
- content: What is the role of firewall rules in Azure SQL server?
15+
choices:
16+
- content: To create a unique server name
17+
isCorrect: false
18+
explanation: Incorrect. Firewall rules don't contribute to creating a unique server name.
19+
- content: To specify which traffic is allowed or denied access to the server
20+
isCorrect: true
21+
explanation: Correct. Firewall rules in Azure SQL server are used to control traffic access to the server.
22+
- content: To generate pseudorandom integers
23+
isCorrect: false
24+
explanation: Incorrect. Firewall rules aren't used for generating pseudorandom integers.
25+
- content: What is the purpose of DACPAC deployment in database management?
26+
choices:
27+
- content: It's used to create a backup of the database for recovery purposes.
28+
isCorrect: false
29+
explanation: Incorrect. While DACPAC can be used for backup, its primary purpose is to package database changes for deployment.
30+
- content: It simplifies the process of deploying database changes by packaging them into a data-tier Application Component (DAC) package.
31+
isCorrect: true
32+
explanation: Correct. DACPAC deployment packages database changes, ensuring consistency and reliability in database deployments.
33+
- content: It's used to monitor the performance of the database.
34+
isCorrect: false
35+
explanation: Incorrect. DACPAC deployment isn't related to performance monitoring.
36+
- content: What is the role of Azure Pipelines in Azure DevOps Services?
37+
choices:
38+
- content: Azure Pipelines automatically build, test, and deploy code, supporting continuous integration and continuous deployment of Azure SQL Database modifications.
39+
isCorrect: true
40+
explanation: Correct. Azure Pipelines ensure that database changes are consistently and reliably applied.
41+
- content: Azure Pipelines are used to encrypt the data of the application.
42+
isCorrect: false
43+
explanation: Incorrect. Azure Pipelines don't encrypt data, they support CI/CD of Azure SQL Database modifications.
44+
- content: Azure Pipelines are used to store the data of the application.
45+
isCorrect: false
46+
explanation: Incorrect. Azure Pipelines don't store data, they build, test, and deploy code.
47+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn-wwl.develop-azure-sql-database.summary
3+
title: Summary
4+
metadata:
5+
title: Summary
6+
description: "Summary"
7+
ms.date: 9/27/2024
8+
author: jupadrao
9+
ms.author: jupadrao
10+
ms.topic: unit
11+
durationInMinutes: 4
12+
content: |
13+
[!include[](includes/8-summary.md)]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
In most modern application projects, databases play a crucial role in enabling efficient data storage, retrieval, and management. Whether you're capturing inputs from a web-based front-end or integrating a database into a larger solution, coding is often necessary to create and manage these databases. As a developer, understanding the intricacies of databases is essential for building robust and scalable applications.
2+
3+
With Azure SQL Database, developers can use advanced capabilities such as built-in security, performance optimization, and seamless scalability. These technologies also support the latest innovations in the Microsoft Intelligent Data Platform, ensuring that developers can meet the diverse needs of their applications, from local development to cloud-based solutions.
4+
5+
In this module, you'll learn about different methods to develop and automate Azure SQL Database publishing for development purposes.
6+
7+
>[!TIP]
8+
> Before proceeding, make sure you have completed the [Get started with Azure SQL Database for modern application development module](/training/modules/get-started-sql-database-application-development?azure-portal=true).
9+
10+
## Simplify continuous integration (CI) and continuous deployment (CD) processes
11+
12+
Including database creation and changes as part of the continuous integration (CI) and continuous deployment (CD) process offers several benefits for developers.
13+
14+
- **Consistency and reliability:** Automating database creation and changes ensures that every environment (development, testing, staging, and production) is set up consistently. This reduces the risk of human error and ensures that the database schema and data are reliable across all environments.
15+
16+
- **Faster development cycles:** By integrating database creation and changes into the CI/CD pipeline, developers can quickly spin up new environments for testing and development. This accelerates the development process and allows for more frequent releases.
17+
18+
- **Improved collaboration:** With database creation and changes automated, teams can work more collaboratively. Developers, testers, and operations teams can all work with the same database setup, leading to better communication and fewer misunderstandings.
19+
20+
- **Version control:** With the version control of the database schema, any changes to the database can be tracked, reviewed, and rolled back if necessary, providing a clear history of database changes.
21+
22+
- **Continuous testing:** Every time a change is made to the codebase, the CI/CD pipeline can automatically create a new database, run tests, and ensure that everything works as expected before deploying to production.
23+
24+
- **Scalability:** Automating database creation and changes makes it easier to scale applications. As the application grows, new databases can be created automatically to handle increased load, ensuring that the application remains performant.
25+
26+
These benefits collectively lead to more efficient development processes, higher quality software, and faster delivery times.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
You can create Azure SQL Databases using code or manually through the Azure portal. Additionally, you can integrate database creation into an automated continuous integration (CI) process. This approach is beneficial for maintaining consistency, as writing code to create a database ensures that you're always generating the exact same specifications each time.
2+
3+
When you create an Azure SQL Database using code, there are four main steps:
4+
5+
1. Create a resource group
6+
1. Create a SQL server
7+
1. Configure firewall rules
8+
1. Create a database
9+
10+
## Create a resource group
11+
12+
All resources in Azure are created within a resource group. When creating a resource group with code, you won't have the same visibility that you have when you create a database in the portal. If you need to include resource group creation in your automated deployment, consider using a randomized name. This approach helps prevent any duplication with existing resource group names in your tenant.
13+
14+
> [!NOTE]
15+
> `$RANDOM` is a Bash function that returns a pseudorandom integer in the range 0 - 32767. This is a smaller range than that returned by PowerShell `Get-Random`. To ensure uniqueness, two `$RANDOM` results can be multiplied together.
16+
17+
For more information about creating a resource group using code, see [Manage Azure Resource Groups by using Azure CLI](/azure/azure-resource-manager/management/manage-resource-groups-cli?azure-portal=true) or [Manage Azure Resource Groups by using Azure PowerShell](/azure/azure-resource-manager/management/manage-resource-groups-powershell?azure-portal=true).
18+
19+
## Create a SQL server
20+
21+
When you create a SQL server, the server name must also be unique, and an Admin user must be created, with a strong password.
22+
23+
This example uses Azure CLI to create a SQL server:
24+
25+
```azurecli
26+
serverName="svr-$randomId"
27+
adminUser="azureadmin"
28+
adminPassword="pw-$randomId"
29+
az sql server create --name $serverName --resource-group $resourceGroup --location $location \
30+
--admin-user $adminUser --admin-password $adminPassword
31+
```
32+
33+
This example uses PowerShell to create a SQL server:
34+
35+
```powershell
36+
$serverName = "svr-$randomId"
37+
$adminUser = "azureadmin"
38+
$adminPassword = "pw-$randomId"
39+
40+
$credentials = New-Object -TypeName System.Management.Automation.PSCredential `
41+
-ArgumentList $adminUser, $(ConvertTo-SecureString -String $adminPassword -AsPlainText -Force)
42+
43+
$server = New-AzSqlServer -ServerName $serverName -ResourceGroupName $resourceGroup `
44+
-Location $location -SqlAdministratorCredentials $credentials
45+
46+
$server
47+
```
48+
49+
## Configure firewall rules
50+
51+
Firewall rules specify which traffic is allowed or denied access to the server.
52+
53+
This example uses Azure CLI to add a firewall rule:
54+
55+
```azurecli
56+
startIpAddress="0.0.0.0"
57+
endIpAddress="0.0.0.0"
58+
firewallRuleName="AllowedIPRange"
59+
60+
az sql server firewall-rule create --server $serverName \
61+
--resource-group $resourceGroup \
62+
--name $firewallRuleName --start-ip-address $startIpAddress --end-ip-address $endIpAddress
63+
```
64+
65+
This example uses PowerShell to add a firewall rule:
66+
67+
```powershell
68+
$startIpAddress = "0.0.0.0"
69+
$endIpAddress = "0.0.0.0"
70+
$firewallRuleName = "AllowedIPRange"
71+
72+
$serverFirewallRule = New-AzSqlServerFirewallRule -ServerName $serverName `
73+
-ResourceGroupName $resourceGroup `
74+
-FirewallRuleName $firewallRuleName -StartIpAddress $startIpAddress -EndIpAddress $endIpAddress
75+
76+
$serverFirewallRule
77+
78+
```
79+
80+
## Create a database
81+
82+
You're now ready to create an Azure SQL Database on the server you created. In this code example, you'll create the sample database *AdventureWorksLT*. If you want to create an empty database, change the database name, and remove the line with the `--sample-name` parameter.
83+
84+
The following code snippet uses Azure CLI to create the *AdventureWorksLT* database.
85+
86+
```azurecli
87+
az sql db create --name AdventureWorksLT
88+
\ --resource-group $resourceGroup --server $serverName
89+
\ --sample-name AdventureWorksLT
90+
\ --edition GeneralPurpose --compute-model serverless --family Gen5 --capacity 2
91+
```
92+
93+
The following code snippet uses PowerShell to create the *AdventureWorksLT* database.
94+
95+
```powershell
96+
New-AzSqlDatabase -DatabaseName AdventureWorksLT `
97+
-ResourceGroupName $resourceGroup -ServerName $serverName `
98+
-SampleName AdventureWorksLT `
99+
-Edition GeneralPurpose -ComputeModel Serverless -ComputeGeneration Gen5 -VCore 2
100+
101+
```
102+
103+
The code snippet demonstrates creating an Azure SQL Database for one particular service tier, and compute tier. To get more information about the service and compute tiers available, see [Service tiers](/azure/azure-sql/database/sql-database-paas-overview?azure-portal=true).
104+
105+
## Query the database
106+
107+
You can create an Azure SQL Database using T-SQL if you have a resource group and server already created in Azure. T-SQL doesn't provide the ability to create Azure resources.
108+
109+
You can, however, query an existing database using the **Query editor** in the Azure portal by going to your [Azure SQL dashboard](https://portal.azure.com/#view/HubsExtension/BrowseResource/resourceType/Microsoft.Sql%2Fazuresql?azure-portal=true).
110+
111+
To get started, sign in to the Azure portal and navigate to your database. From the left navigation pane, select **Query editor**. Then, sign in with your SQL administrator credentials. Once you're signed in, run the following T-SQL query against the *AdventureWorksLT* database.
112+
113+
```SQL
114+
SELECT TOP 10 C.Name AS Category, SUM(S.OrderQty * S.UnitPrice) AS SalesValue
115+
FROM [SalesLT].[ProductCategory] AS C
116+
INNER JOIN [SalesLT].[Product] AS P
117+
ON C.ProductCategoryID = P.ProductCategoryID
118+
INNER JOIN [SalesLT].[SalesOrderDetail] AS S
119+
ON P.ProductID = S.ProductID
120+
GROUP BY C.Name
121+
ORDER BY SalesValue DESC;
122+
```
123+
124+
For more information Azure SQL Database deployment models available, see [What is Azure SQL Database?](/azure/azure-sql/database/sql-database-paas-overview?azure-portal=true).

0 commit comments

Comments
 (0)