Skip to content

Commit 5c1602e

Browse files
committed
Merge branch 'main' into release-2022-cu08
2 parents 5c5fda2 + 342d072 commit 5c1602e

73 files changed

Lines changed: 847 additions & 794 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

azure-sql/database/connect-query-go.md

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,74 @@
11
---
22
title: Use Go to query
33
titleSuffix: Azure SQL Database & SQL Managed Instance
4-
description: Use Go to create a program that connects to a database in Azure SQL Database or Azure SQL Managed Instance, and runs queries.
4+
description: "Quickstart: Use Go to create a program that connects to a database in Azure SQL Database or Azure SQL Managed Instance, and runs queries."
55
author: dlevy-msft
66
ms.author: dlevy
7-
ms.reviewer: wiassaf, mathoma
8-
ms.date: 08/29/2023
7+
ms.reviewer: wiassaf, mathoma, randolphwest
8+
ms.date: 09/12/2023
99
ms.service: sql-database
1010
ms.subservice: connect
1111
ms.topic: quickstart
1212
ms.custom:
1313
- sqldbrb=2
1414
- mode-api
1515
ms.devlang: golang
16-
monikerRange: "= azuresql || = azuresql-db || = azuresql-mi"
16+
monikerRange: "=azuresql || =azuresql-db || =azuresql-mi"
1717
---
1818
# Quickstart: Use Golang to query a database in Azure SQL Database or Azure SQL Managed Instance
19-
[!INCLUDE[appliesto-sqldb-sqlmi](../includes/appliesto-sqldb-sqlmi.md)]
2019

21-
In this quickstart, you'll use the Golang programming language to connect to an Azure SQL Database or a database in Azure SQL Managed Instance with the [go-mssqldb](https://github.com/microsoft/go-mssqldb) driver. The sample queries and modifies data with explicit Transact-SQL statements. [Golang](https://go.dev/) is an open-source programming language that makes it easy to build simple, reliable, and efficient software.
20+
[!INCLUDE [appliesto-sqldb-sqlmi](../includes/appliesto-sqldb-sqlmi.md)]
21+
22+
In this quickstart, you'll use the Golang programming language to connect to an Azure SQL database, or a database in [!INCLUDE [ssazuremi_md](../../docs/includes/ssazuremi_md.md)], with the [go-mssqldb](https://github.com/microsoft/go-mssqldb) driver. The sample queries and modifies data with explicit Transact-SQL (T-SQL) statements. [Golang](https://go.dev/) is an open-source programming language that makes it easy to build simple, reliable, and efficient software.
2223

2324
## Prerequisites
2425

2526
To complete this quickstart, you need:
2627

27-
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
28-
- An Azure SQL Database or a database in Azure SQL Managed Instance. You can use one of these quickstarts to create a database:
28+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/).
29+
- An Azure SQL database or a database in [!INCLUDE [ssazuremi_md](../../docs/includes/ssazuremi_md.md)]. You can use one of these quickstarts to create a database:
2930

30-
|| SQL Database | SQL Managed Instance | SQL Server on Azure VM |
31-
|:--- |:--- |:---|:---|
32-
| **Create**| [Portal](single-database-create-quickstart.md) | [Portal](../managed-instance/instance-create-quickstart.md) | [Portal](../virtual-machines/windows/sql-vm-create-portal-quickstart.md)
31+
| | SQL Database | SQL Managed Instance | SQL Server on Azure VM |
32+
| :--- | :--- | :--- | :--- |
33+
| **Create**| [Portal](single-database-create-quickstart.md) | [Portal](../managed-instance/instance-create-quickstart.md) | [Portal](../virtual-machines/windows/sql-vm-create-portal-quickstart.md) |
3334
| **Create** | [CLI](scripts/create-and-configure-database-cli.md) | [CLI](https://medium.com/azure-sqldb-managed-instance/working-with-sql-managed-instance-using-azure-cli-611795fe0b44) |
34-
| **Create** | [PowerShell](scripts/create-and-configure-database-powershell.md) | [PowerShell](../managed-instance/scripts/create-configure-managed-instance-powershell.md) | [PowerShell](../virtual-machines/windows/sql-vm-create-powershell-quickstart.md)
35-
| **Configure** | [Server-level IP firewall rule](firewall-create-server-level-portal-quickstart.md)| [Connectivity from a VM](../managed-instance/connect-vm-instance-configure.md)|
36-
| **Configure** ||[Connectivity from on-premises](../managed-instance/point-to-site-p2s-configure.md) | [Connect to a SQL Server instance](../virtual-machines/windows/sql-vm-create-portal-quickstart.md)
37-
|**Load data**|AdventureWorks loaded per quickstart|[Restore WideWorldImporters](../managed-instance/restore-sample-database-quickstart.md) | [Restore WideWorldImporters](../managed-instance/restore-sample-database-quickstart.md) |
38-
| **Load data** ||Restore or import AdventureWorks from a [BACPAC](database-import.md) file from [GitHub](https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/adventure-works)| Restore or import AdventureWorks from a [BACPAC](database-import.md) file from [GitHub](https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/adventure-works)|
39-
40-
> [!IMPORTANT]
41-
> The scripts in this article are written to use the AdventureWorks database. With a SQL Managed Instance, you must either import the AdventureWorks database into an instance database or modify the scripts in this article to use the Wide World Importers database.
35+
| **Create** | [PowerShell](scripts/create-and-configure-database-powershell.md) | [PowerShell](../managed-instance/scripts/create-configure-managed-instance-powershell.md) | [PowerShell](../virtual-machines/windows/sql-vm-create-powershell-quickstart.md) |
36+
| **Configure** | [Server-level IP firewall rule](firewall-create-server-level-portal-quickstart.md) | [Connectivity from a VM](../managed-instance/connect-vm-instance-configure.md) |
37+
| **Configure** | | [Connectivity from on-premises](../managed-instance/point-to-site-p2s-configure.md) | [Connect to a SQL Server instance](../virtual-machines/windows/sql-vm-create-portal-quickstart.md) |
38+
| **Load data** | [!INCLUDE [sssampledbobject-md](../../docs/includes/sssampledbobject-md.md)] loaded per quickstart | [Restore WideWorldImporters](../managed-instance/restore-sample-database-quickstart.md) | [Restore WideWorldImporters](../managed-instance/restore-sample-database-quickstart.md) |
39+
| **Load data** | | Restore or import [!INCLUDE [sssampledbobject-md](../../docs/includes/sssampledbobject-md.md)] from a [BACPAC](database-import.md) file from [GitHub](https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/adventure-works) | Restore or import [!INCLUDE [sssampledbobject-md](../../docs/includes/sssampledbobject-md.md)] from a [BACPAC](database-import.md) file from [GitHub](https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/adventure-works) |
4240

43-
- Golang and related software for your operating system installed:
41+
> [!IMPORTANT]
42+
> The scripts in this article are written to use the [!INCLUDE [sssampledbobject-md](../../docs/includes/sssampledbobject-md.md)] database. With a SQL managed instance, you must either import the [!INCLUDE [sssampledbobject-md](../../docs/includes/sssampledbobject-md.md)] database into an instance database or modify the scripts in this article to use the Wide World Importers database.
4443
45-
- **macOS**: Install Homebrew and Golang. See [Step 1.2](https://www.microsoft.com/sql-server/developer-get-started/go/mac/).
46-
- **Ubuntu**: Install Golang. See [Step 1.2](https://www.microsoft.com/sql-server/developer-get-started/go/ubuntu/).
47-
- **Windows**: Install Golang. See [Step 1.2](https://www.microsoft.com/sql-server/developer-get-started/go/windows/).
44+
- [Go](https://go.dev/doc/install) and related software for your operating system installed.
4845

4946
- The [Azure PowerShell Az module](/powershell/azure/install-azure-powershell) for your operating system installed.
50-
47+
5148
## Get server connection information
5249

5350
Get the connection information you need to connect to the database. You'll need the fully qualified server name or host name, database name, and login information for the upcoming procedures.
5451

5552
1. Sign in to the [Azure portal](https://portal.azure.com/).
5653

57-
2. Navigate to the **SQL Databases** or **SQL Managed Instances** page.
54+
1. Navigate to the **SQL Databases** or **SQL Managed Instances** page.
5855

59-
3. On the **Overview** page, review the fully qualified server name next to **Server name** for a database in Azure SQL Database or the fully qualified server name (or IP address) next to **Host** for an Azure SQL Managed Instance or SQL Server on Azure VM. To copy the server name or host name, hover over it and select the **Copy** icon.
56+
1. On the **Overview** page, review the fully qualified server name next to **Server name** for a database in Azure SQL Database or the fully qualified server name (or IP address) next to **Host** for an Azure SQL Managed Instance or SQL Server on Azure VM. To copy the server name or host name, hover over it and select the **Copy** icon.
6057

61-
> [!NOTE]
58+
> [!NOTE]
6259
> For connection information for SQL Server on Azure VM, see [Connect to a SQL Server instance](../virtual-machines/windows/sql-vm-create-portal-quickstart.md#connect-to-sql-server).
6360
6461
## Create a new folder for the Golang project and dependencies
6562

66-
1. From the terminal, create a new project folder called **SqlServerSample**.
63+
1. From the terminal, create a new project folder called `SqlServerSample`.
6764

6865
```bash
6966
mkdir SqlServerSample
7067
```
7168

7269
## Create sample data
7370

74-
1. In a text editor, create a file called **CreateTestData.sql** in the **SqlServerSample** folder. In the file, paste this T-SQL code, which creates a schema, table, and inserts a few rows.
71+
1. In a text editor, create a file called `CreateTestData.sql` in the `SqlServerSample` folder. In the file, paste this T-SQL code, which creates a schema, table, and inserts a few rows.
7572

7673
```sql
7774
CREATE SCHEMA TestSchema;
@@ -94,7 +91,7 @@ Get the connection information you need to connect to the database. You'll need
9491
GO
9592
```
9693

97-
2. At the command prompt, navigate to **SqlServerSample** and use `sqlcmd` to connect to the database and run your newly created Azure SQL script. Replace the appropriate values for your server and database.
94+
1. At the command prompt, navigate to `SqlServerSample` and use `sqlcmd` to connect to the database and run your newly created Azure SQL script. Replace the appropriate values for your server and database.
9895

9996
```bash
10097
az login
@@ -103,9 +100,9 @@ Get the connection information you need to connect to the database. You'll need
103100

104101
## Insert code to query the database
105102

106-
1. Create a file named **sample.go** in the **SqlServerSample** folder.
103+
1. Create a file named `sample.go` in the `SqlServerSample` folder.
107104

108-
2. In the file, paste this code. Add the values for your server and database. This example uses the Golang [context methods](https://go.dev/pkg/context/) to make sure there's an active connection.
105+
1. In the file, paste this code. Add the values for your server and database. This example uses the Golang [context methods](https://go.dev/pkg/context/) to make sure there's an active connection.
109106

110107
```go
111108
package main
@@ -301,23 +298,23 @@ Get the connection information you need to connect to the database. You'll need
301298

302299
## Get Golang project dependencies and run the code
303300

304-
1. At the command prompt, navigate to **SqlServerSample** and install the SQL Server driver for Go by running the following commands.
301+
1. At the command prompt, navigate to `SqlServerSample` and install the SQL Server driver for Go by running the following commands.
305302

306303
```bash
307304
go mod init SqlServerSample
308305
go mod tidy
309306
```
310307

311-
2. At the command prompt, run the following command.
308+
1. At the command prompt, run the following command.
312309

313310
```bash
314-
az login
311+
az login
315312
go run sample.go
316313
```
317314

318-
3. Verify the output.
315+
1. Verify the output.
319316

320-
```text
317+
```output
321318
Connected!
322319
Inserted ID: 4 successfully.
323320
ID: 1, Name: Jared, Location: Australia

azure-sql/database/geo-distributed-application-configure-tutorial.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ To complete the tutorial, make sure you've installed the following items:
4444
> [!NOTE]
4545
> The tutorial uses the *AdventureWorksLT* sample database.
4646
47-
- Java and Maven, see [Build an app using SQL Server](https://www.microsoft.com/sql-server/developer-get-started/), highlight **Java** and select your environment, then follow the steps.
48-
4947
> [!IMPORTANT]
5048
> Be sure to set up firewall rules to use the public IP address of the computer on which you're performing the steps in this tutorial. Database-level firewall rules will replicate automatically to the secondary server.
5149
>

azure-sql/database/resource-limits-logical-server.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: This article provides an overview of resource management in Azure S
44
author: dimitri-furman
55
ms.author: dfurman
66
ms.reviewer: wiassaf, mathoma, randolphwest
7-
ms.date: 08/30/2023
7+
ms.date: 09/12/2023
88
ms.service: sql-database
99
ms.subservice: service-overview
1010
ms.topic: reference
@@ -146,7 +146,7 @@ If you get out-of-memory errors, mitigation options include:
146146

147147
## Resource consumption by user workloads and internal processes
148148

149-
Azure SQL Database requires compute resources to implement core service features such as high availability and disaster recovery, database backup and restore, monitoring, Query Store, Automatic tuning, etc. The system sets aside a certain limited portion of the overall resources for these internal processes using [resource governance](#resource-governance) mechanisms, making the remainder of resources available for user workloads. When internal processes aren't using compute resources, the system makes them available to user workloads.
149+
Azure SQL Database requires compute resources to implement core service features such as high availability and disaster recovery, database backup and restore, monitoring, Query Store, Automatic tuning, etc. The system sets aside a limited portion of the overall resources for these internal processes using [resource governance](#resource-governance) mechanisms, making the remainder of resources available for user workloads. At times when internal processes aren't using compute resources, the system makes them available to user workloads.
150150

151151
Total CPU and memory consumption by user workloads and internal processes is reported in the [sys.dm_db_resource_stats](/sql/relational-databases/system-dynamic-management-views/sys-dm-db-resource-stats-azure-sql-database) and [sys.resource_stats](/sql/relational-databases/system-catalog-views/sys-resource-stats-azure-sql-database) views, in `avg_instance_cpu_percent` and `avg_instance_memory_percent` columns. This data is also reported via the `sql_instance_cpu_percent` and `sql_instance_memory_percent` Azure Monitor metrics, for [single databases](/azure/azure-monitor/essentials/metrics-supported#microsoftsqlserversdatabases) and [elastic pools](/azure/azure-monitor/essentials/metrics-supported#microsoftsqlserverselasticpools) at the pool level.
152152

@@ -160,9 +160,15 @@ A more detailed breakdown of recent resource consumption by user workloads and i
160160
> [!TIP]
161161
> When monitoring or troubleshooting workload performance, it's important to consider both **user CPU consumption** (`avg_cpu_percent`, `cpu_percent`), and **total CPU consumption** by user workloads and internal processes (`avg_instance_cpu_percent`,`sql_instance_cpu_percent`). Performance may be noticeably impacted if *either* of these metrics is in the 70-100% range.
162162
163-
**User CPU consumption** is calculated as a percentage of the user workload limits in each service objective. **User CPU utilization** in the 70-100% range indicates that the user workload is reaching the limit of the service objective. However, when **total CPU consumption** reaches the 70-100% range, it's possible to see user workload throughput flattening out and query latency increasing, even if reported **user CPU consumption** remains significantly below 100%. This is more likely to occur when using smaller service objectives with a moderate allocation of compute resources, but relatively intense user workloads, such as in [dense elastic pools](elastic-pool-resource-management.md). This can also occur with smaller service objectives when internal processes temporarily require more resources, for example when creating a new replica of the database, or backing up the database.
163+
**User CPU consumption** is defined as a percentage toward the user workload CPU limit in each service objective. Likewise, **total CPU consumption** is defined as a percentage toward the CPU limit for all workloads. Because the two limits are different, the user and total CPU consumption are measured on different scales, and are not directly comparable with each other.
164164

165-
When **total CPU consumption** is high, mitigation options are the same as noted in the [Compute CPU](#compute-cpu) section, and include service objective increase and/or user workload optimization.
165+
When either **user CPU utilization** or **total CPU consumption** is the 70-100% range, a service objective limit is being reached.
166+
167+
When **total CPU consumption** reaches the 70-100% range, it's possible to see user workload throughput flattening and query latency increasing, even if **user CPU consumption** remains significantly below 100%. This is more likely to occur when using smaller service objectives with a moderate allocation of compute resources, but relatively intense user workloads, such as in [dense elastic pools](elastic-pool-resource-management.md). This can also occur with smaller service objectives when internal processes temporarily require additional resources, for example when creating a new replica of the database, or backing up the database.
168+
169+
Likewise, when **user CPU consumption** reaches the 70-100% range, user workload throughput will flatten and query latency will increase, even though **total CPU consumption** may be well below its limit.
170+
171+
When either **user CPU consumption** or **total CPU consumption** is high, mitigation options are the same as noted in the [Compute CPU](#compute-cpu) section, and include service objective increase and/or user workload optimization.
166172

167173
> [!NOTE]
168174
> Even on a completely idle database or elastic pool, **total CPU consumption** is never at zero because of background database engine activities. It can fluctuate in a wide range depending on the specific background activities, compute size, and previous user workload.

0 commit comments

Comments
 (0)