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: azure-sql/database/xevent-code-event-file.md
+29-8Lines changed: 29 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Provides example steps to create an event session in Azure SQL, usi
5
5
author: WilliamDAssafMSFT
6
6
ms.author: wiassaf
7
7
ms.reviewer: wiassaf, mathoma, randolphwest
8
-
ms.date: 10/21/2024
8
+
ms.date: 07/09/2025
9
9
ms.service: azure-sql
10
10
ms.subservice: performance
11
11
ms.topic: sample
@@ -23,20 +23,21 @@ The high-level steps in this walkthrough are:
23
23
1. Create an Azure Storage account, or find an existing suitable account to use.
24
24
1. Create a container in this storage account.
25
25
1. Grant the [!INCLUDE [ssde-md](../../docs/includes/ssde-md.md)] required access to the container using either an RBAC role assignment, or a SAS token.
26
-
1. Create a credential in the database or managed instance where you create the event session.
26
+
1. Create a credential in the database or SQL managed instance where you create the event session.
27
27
1. Create, start, and use an event session.
28
28
29
29
## Create a storage account and container
30
30
31
31
For a detailed description of how to create a storage account in Azure Storage, see [Create a storage account](/azure/storage/common/storage-account-create). You learn how to create a storage account using Azure portal, PowerShell, Azure SQL, an ARM template, or a Bicep template.
32
32
33
-
We recommended you use an account that:
33
+
Use an account that:
34
34
35
35
- Is a `Standard general-purpose v2` account.
36
36
- Has its redundancy type matching the redundancy of the Azure SQL database, elastic pool, or managed instance where event sessions are created.
37
37
- For [locally redundant](high-availability-sla-local-zone-redundancy.md#locally-redundant-availability) Azure SQL resources, use LRS, GRS, or RA-GRS. For [zone-redundant](high-availability-sla-local-zone-redundancy.md#zone-redundant-availability) Azure SQL resources, use ZRS, GZRS, or RA-GZRS. For more information, see [Azure Storage redundancy](/azure/storage/common/storage-redundancy).
38
38
- Uses the `Hot`[blob access tier](/azure/storage/blobs/access-tiers-overview).
39
39
- Is in the same Azure region as the Azure SQL database, elastic pool, or managed instance.
40
+
- Doesn't have the [hierarchical namespace](/azure/storage/blobs/data-lake-storage-namespace) enabled.
40
41
41
42
Next, [create a container](/azure/storage/blobs/blob-containers-portal#create-a-container) in this storage account using Azure portal. You can also create a container [using PowerShell](/azure/storage/blobs/blob-containers-powershell#create-a-container), or [using Azure CLI](/azure/storage/blobs/blob-containers-cli#create-a-container).
42
43
@@ -96,10 +97,10 @@ To read and write event data, the [!INCLUDE [ssde-md](../../docs/includes/ssde-m
96
97
97
98
# [SQL Managed Instance](#tab/sqlmi)
98
99
99
-
Create a server-scoped [credential](/sql/relational-databases/security/authentication-access/credentials-database-engine). Using a client tool such as SSMS or ADS, open a new query window, connect it to the `master` database on the managed instance where you create the event session, and paste the following T-SQL batch.
100
+
Create a server-scoped [credential](/sql/relational-databases/security/authentication-access/credentials-database-engine). Using a client tool such as SSMS or ADS, open a new query window, connect it to the `master` database on the SQL managed instance where you create the event session, and paste the following T-SQL batch.
100
101
101
102
> [!NOTE]
102
-
> Executing the following T-SQL batch requires the `CONTROL` database permission in the `master` database, which is held by the members of the `db_owner` database role in`master`, and by the members of the `sysadmin` server role on the managed instance.
103
+
> Executing the following T-SQL batch requires the `CONTROL` database permission in the `master` database, which is held by the members of the `db_owner` database role in`master`, and by the members of the `sysadmin` server role on the SQL managed instance.
103
104
104
105
```sql
105
106
/*
@@ -188,10 +189,10 @@ To read and write event data, the [!INCLUDE [ssde-md](../../docs/includes/ssde-m
188
189
189
190
# [SQL Managed Instance](#tab/sqlmi)
190
191
191
-
Store the SAS token in a server-scoped [credential](/sql/relational-databases/security/authentication-access/credentials-database-engine). Using a client tool such as SSMS or ADS, open a new query window, connect it to the `master` database on the managed instance where you create the event session, and paste the following T-SQL batch.
192
+
Store the SAS token in a server-scoped [credential](/sql/relational-databases/security/authentication-access/credentials-database-engine). Using a client tool such as SSMS or ADS, open a new query window, connect it to the `master` database on the SQL managed instance where you create the event session, and paste the following T-SQL batch.
192
193
193
194
> [!NOTE]
194
-
> Executing the following T-SQL batch requires the `CONTROL` database permission in the `master` database, which is held by the members of the `db_owner` database role in`master`, and by the members of the `sysadmin` server role on the managed instance.
195
+
> Executing the following T-SQL batch requires the `CONTROL` database permission in the `master` database, which is held by the members of the `db_owner` database role in`master`, and by the members of the `sysadmin` server role on the SQL managed instance.
195
196
196
197
```sql
197
198
/*
@@ -271,10 +272,30 @@ Select **OK** to create the session.
271
272
272
273
In Object Explorer, expand the **Sessions** folder to see the event session you created. By default, the session isn't started when it's created. To start the session, right-click on the session name, andselect**Start Session**. You can later stop it by similarly selecting **Stop Session**, once the session is running.
273
274
274
-
As T-SQL batches are executed in this database or managed instance, the session writes events to the `example-session.xel` blob in the storage container.
275
+
As T-SQL batches are executed in this database orSQL managed instance, the session writes events to the `example-session.xel` blob in the storage container.
275
276
276
277
To stop the session, right-click it in Object Explorer, andselect**Stop Session**.
277
278
279
+
### Troubleshoot event sessions with an event_file target in Azure Storage
280
+
281
+
The following list contains errors that you might encounter when starting an extended event session that uses Azure Storage, with the possible explanations for the error.
282
+
283
+
-**The operating system returned error 5: 'Access is denied.'**
284
+
- If using managed identity authentication:
285
+
- The managed identity of a logical server or SQL managed instance doesn't have the required RBAC role assignment. For more information, see [Grant access using managed identity](#grant-access-using-managed-identity).
286
+
- The storage account [firewall](/azure/storage/common/storage-network-security) is enabled and an exception to allow trusted Azure services to access the storage account is also enabled, but a `Microsoft.Sql/servers` resource instance for the logical server hasn't been added to the list of resource instances that are granted access. For more information, see [Grant access from Azure resource instances](/azure/storage/common/storage-network-security#grant-access-from-azure-resource-instances).
287
+
- If using SAS token authentication:
288
+
- The storage account [firewall](/azure/storage/common/storage-network-security) is enabled. This is not supported for event sessions that use SAS token authentication.
289
+
- The SAS token doesn't have sufficient permissions, or has expired. For more information, see [Grant access using a SAS token](#grant-access-using-a-sas-token).
290
+
- **The operating system returned error 86: 'The specified network password is not correct'**
291
+
- There is no database-scoped credential (for Azure SQL Database) or server-scoped credential (for Azure SQL Managed Instance) with the name matching the blob container URL. For more information, see the examples in [Grant access to the container](#grant-access-to-the-container).
292
+
- The credential name ends with a slash (`/`). The credential name should end with the container name not including the trailing slash.
293
+
- **The operating system returned error 3: 'The system cannot find the path specified'**
294
+
- The container specified in the blob container URL doesn't exist.
295
+
-**The operating system returned error 13: 'The data is invalid'**
296
+
- There is an [immutability policy](/azure/storage/blobs/immutable-policy-configure-container-scope) on the blob container. Immutable storage isn't supported for event sessions.
297
+
- The storage account has the [hierarchical namespace](/azure/storage/blobs/data-lake-storage-namespace) enabled. Storage accounts with hierarchical namespace enabled aren't supported for event sessions.
298
+
278
299
## View event data
279
300
280
301
You can view event data in the SQL Server Management Studio (SSMS) event viewer UI, where you can use filters and aggregations to analyze the data you captured. For more information on using the event viewer in SSMS, see [View event data in SSMS](/sql/relational-databases/extended-events/advanced-viewing-of-target-data-from-extended-events-in-sql-server).
Copy file name to clipboardExpand all lines: azure-sql/database/xevent-db-diff-from-svr.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Describes extended events (XEvents) in Azure SQL Database and Azure
5
5
author: WilliamDAssafMSFT
6
6
ms.author: wiassaf
7
7
ms.reviewer: wiassaf, mathoma, randolphwest
8
-
ms.date: 10/21/2024
8
+
ms.date: 07/09/2025
9
9
ms.service: azure-sql
10
10
ms.subservice: performance
11
11
ms.topic: reference
@@ -36,7 +36,7 @@ The feature set, functionality, and usage scenarios for Extended Events in Azure
36
36
37
37
There are two examples to help you get started with Extended Events in Azure SQL Database and Azure SQL Managed Instance quickly:
38
38
39
-
-[Create a session with an event_file target in Azure Storage](xevent-code-event-file.md). This example shows you how to capture event data in a file (blob) in Azure Storage using the `event_file` target. Use this if you need to persist captured event data, or if you want to use event viewer in SQL Server Management Studio (SSMS) to analyze captured data.
39
+
-[Create a session with an event_file target in Azure Storage](xevent-code-event-file.md). This example shows you how to capture event data in a file (blob) in Azure Storage using the `event_file` target, and includes [troubleshooting guidance](xevent-code-event-file.md#troubleshoot-event-sessions-with-an-event_file-target-in-azure-storage) for common errors. Use this if you need to persist captured event data, or if you want to use event viewer in SQL Server Management Studio (SSMS) to analyze captured data.
40
40
-[Create a session with a ring_buffer target in memory](xevent-code-ring-buffer.md). This example shows you how to capture the latest events from an event session in memory using the `ring_buffer` target. Use this as a quick way to look at recent events during ad hoc investigations or troubleshooting, without having to store captured event data.
41
41
42
42
Extended Events can be used to monitor read-only replicas. For more information, see [Read queries on replicas](read-scale-out.md#monitor-read-only-replicas-with-extended-events).
@@ -49,6 +49,7 @@ Adopt the following best practices to use Extended Events in Azure SQL Database
49
49
- Use a storage account in the same Azure region as the database or managed instance where you create event sessions.
50
50
- Align the redundancy of the storage account with the redundancy of the database, elastic pool, or managed instance. For [locally redundant](high-availability-sla-local-zone-redundancy.md#locally-redundant-availability) resources, use LRS, GRS, or RA-GRS. For [zone-redundant](high-availability-sla-local-zone-redundancy.md#zone-redundant-availability) resources, use ZRS, GZRS, or RA-GZRS. See [Azure Storage redundancy](/azure/storage/common/storage-redundancy) for details.
51
51
- Don't use any [blob access tier](/azure/storage/blobs/access-tiers-overview) other than `Hot`.
52
+
- Don't enable the [hierarchical namespace](/azure/storage/blobs/data-lake-storage-namespace) for the storage account.
52
53
- If you want to create a continuously running event session that starts automatically after each [!INCLUDE [ssde-md](../../docs/includes/ssde-md.md)] restart (for example, after a failover or a maintenance event), include the event session option of `STARTUP_STATE = ON` in your `CREATE EVENT SESSION` or `ALTER EVENT SESSION` statements.
53
54
- Conversely, use `STARTUP_STATE = OFF` for short-term event sessions such as those used in ad hoc troubleshooting.
54
55
- In Azure SQL Database, do not read deadlock events from the built-in `dl` event session. If there is a large number of deadlock events collected, reading them with the [sys.fn_xe_file_target_read_file()](/sql/relational-databases/system-functions/sys-fn-xe-file-target-read-file-transact-sql) function can cause an out-of-memory error in the `master` database. This might impact login processing and result in an application outage. For the recommended ways to monitor deadlocks, see [Collect deadlock graphs in Azure SQL Database with Extended Events](analyze-prevent-deadlocks.md#collect-deadlock-graphs-in-azure-sql-database-with-extended-events).
0 commit comments