Skip to content

Commit 248179e

Browse files
Add event_file target troubleshooting
1 parent 72be940 commit 248179e

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

azure-sql/database/xevent-code-event-file.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Provides example steps to create an event session in Azure SQL, usi
55
author: WilliamDAssafMSFT
66
ms.author: wiassaf
77
ms.reviewer: wiassaf, mathoma, randolphwest
8-
ms.date: 10/21/2024
8+
ms.date: 07/09/2025
99
ms.service: azure-sql
1010
ms.subservice: performance
1111
ms.topic: sample
@@ -23,20 +23,21 @@ The high-level steps in this walkthrough are:
2323
1. Create an Azure Storage account, or find an existing suitable account to use.
2424
1. Create a container in this storage account.
2525
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.
2727
1. Create, start, and use an event session.
2828

2929
## Create a storage account and container
3030

3131
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.
3232

33-
We recommended you use an account that:
33+
Use an account that:
3434

3535
- Is a `Standard general-purpose v2` account.
3636
- Has its redundancy type matching the redundancy of the Azure SQL database, elastic pool, or managed instance where event sessions are created.
3737
- 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).
3838
- Uses the `Hot` [blob access tier](/azure/storage/blobs/access-tiers-overview).
3939
- 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.
4041

4142
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).
4243

@@ -96,10 +97,10 @@ To read and write event data, the [!INCLUDE [ssde-md](../../docs/includes/ssde-m
9697

9798
# [SQL Managed Instance](#tab/sqlmi)
9899

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.
100101

101102
> [!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.
103104

104105
```sql
105106
/*
@@ -188,10 +189,10 @@ To read and write event data, the [!INCLUDE [ssde-md](../../docs/includes/ssde-m
188189

189190
# [SQL Managed Instance](#tab/sqlmi)
190191

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.
192193

193194
> [!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.
195196

196197
```sql
197198
/*
@@ -271,10 +272,30 @@ Select **OK** to create the session.
271272

272273
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, and select **Start Session**. You can later stop it by similarly selecting **Stop Session**, once the session is running.
273274

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 or SQL managed instance, the session writes events to the `example-session.xel` blob in the storage container.
275276

276277
To stop the session, right-click it in Object Explorer, and select **Stop Session**.
277278

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+
278299
## View event data
279300

280301
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).

azure-sql/database/xevent-db-diff-from-svr.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Describes extended events (XEvents) in Azure SQL Database and Azure
55
author: WilliamDAssafMSFT
66
ms.author: wiassaf
77
ms.reviewer: wiassaf, mathoma, randolphwest
8-
ms.date: 10/21/2024
8+
ms.date: 07/09/2025
99
ms.service: azure-sql
1010
ms.subservice: performance
1111
ms.topic: reference
@@ -36,7 +36,7 @@ The feature set, functionality, and usage scenarios for Extended Events in Azure
3636

3737
There are two examples to help you get started with Extended Events in Azure SQL Database and Azure SQL Managed Instance quickly:
3838

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.
4040
- [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.
4141

4242
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
4949
- Use a storage account in the same Azure region as the database or managed instance where you create event sessions.
5050
- 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.
5151
- 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.
5253
- 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.
5354
- Conversely, use `STARTUP_STATE = OFF` for short-term event sessions such as those used in ad hoc troubleshooting.
5455
- 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

Comments
 (0)