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
{{ message }}
Repository navigation
Commit 8975152
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: azure-sql/database/xevent-code-event-file.md
+13-17Lines changed: 13 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: XEvent Event File code
3
-
description: Provides PowerShell and Transact-SQL for a two-phase code sample that demonstrates the Event File target in an extended event on Azure SQL Database. Azure Storage is a required part of this scenario.
3
+
description: Provides PowerShell and Transact-SQL for a two-phase code sample that demonstrates the Event File target in an extended event on Azure SQL Database and SQL Managed Instance. Azure Storage is a required part of this scenario.
4
4
services: sql-database
5
5
ms.service: sql-database
6
6
ms.subservice: performance
@@ -10,18 +10,18 @@ ms.topic: sample
10
10
author: WilliamDAssafMSFT
11
11
ms.author: wiassaf
12
12
ms.reviewer: kendralittle, mathoma
13
-
ms.date: 06/06/2020
13
+
ms.date: 03/25/2022
14
14
---
15
-
# Event File target code for extended events in Azure SQL Database
You want a complete code sample for a robust way to capture and report information for an extended event.
21
21
22
-
In Microsoft SQL Server, the [Event File target](/previous-versions/sql/sql-server-2016/ff878115(v=sql.130)) is used to store event outputs into a local hard drive file. But such files are not available to Azure SQL Database. Instead we use the Azure Storage service to support the Event File target.
22
+
In Microsoft SQL Server, the [Event File target](/sql/relational-databases/extended-events/targets-for-extended-events-in-sql-server) is used to store event outputs into a local hard drive file. But local storage is not available to Azure SQL Database or SQL Managed Instance. Instead, use Azure Blob Storage to support the Event File target.
23
23
24
-
This topic presents a two-phase code sample:
24
+
This article presents a two-phase code sample:
25
25
26
26
- PowerShell, to create an Azure Storage container in the cloud.
27
27
- Transact-SQL:
@@ -40,15 +40,11 @@ This topic presents a two-phase code sample:
40
40
41
41
- Optionally you can [create an **AdventureWorksLT** demonstration database](single-database-create-quickstart.md) in minutes.
42
42
43
-
- SQL Server Management Studio (ssms.exe), ideally its latest monthly update version.
44
-
You can download the latest ssms.exe from:
45
-
46
-
- Topic titled [Download SQL Server Management Studio](/sql/ssms/download-sql-server-management-studio-ssms).
47
-
-[A direct link to the download.](https://go.microsoft.com/fwlink/?linkid=616025)
43
+
- SQL Server Management Studio (ssms.exe), ideally its latest monthly update version: [Download SQL Server Management Studio](/sql/ssms/download-sql-server-management-studio-ssms)
48
44
49
45
- You must have the [Azure PowerShell modules](https://go.microsoft.com/?linkid=9811175) installed.
50
46
51
-
- The modules provide commands such as - **New-AzStorageAccount**.
47
+
- The modules provide commands, such as - `New-AzStorageAccount`.
52
48
53
49
## Phase 1: PowerShell code for Azure Storage container
54
50
@@ -244,7 +240,7 @@ The script starts with commands to clean up after a possible previous run, and i
244
240
The PowerShell script printed a few named values when it ended. You must edit the Transact-SQL script to use those values. Find **TODO** in the Transact-SQL script to locate the edit points.
245
241
246
242
1. Open SQL Server Management Studio (ssms.exe).
247
-
2. Connect to your database in Azure SQL Database.
243
+
2. Connect to your database in Azure SQL Database or SQL Managed Instance.
248
244
3. Click to open a new query pane.
249
245
4. Paste the following Transact-SQL script into the query pane.
250
246
5. Find every **TODO** in the script and make the appropriate edits.
@@ -259,7 +255,7 @@ The PowerShell script printed a few named values when it ended. You must edit th
259
255
---- TODO: First, run the earlier PowerShell portion of this two-part code sample.
260
256
---- TODO: Second, find every 'TODO' in this Transact-SQL file, and edit each.
261
257
262
-
---- Transact-SQL code for Event File target on Azure SQL Database.
258
+
---- Transact-SQL code for Event File target on Azure SQL Database or SQL Managed Instance.
263
259
264
260
SET NOCOUNT ON;
265
261
GO
@@ -501,13 +497,13 @@ An explanation of advanced options for the viewing of data from extended events
501
497
502
498
Suppose you wanted to run the preceding Transact-SQL sample on Microsoft SQL Server.
503
499
504
-
- For simplicity, you would want to completely replace use of the Azure Storage container with a simple file such as *C:\myeventdata.xel*. The file would be written to the local hard drive of the computer that hosts SQL Server.
500
+
- For simplicity, you would want to completely replace use of the Azure Storage container with a simple file such as `C:\myeventdata.xel`. The file would be written to the local hard drive of the computer that hosts SQL Server.
505
501
- You would not need any kind of Transact-SQL statements for **CREATE MASTER KEY** and **CREATE CREDENTIAL**.
506
-
- In the **CREATE EVENT SESSION** statement, in its **ADD TARGET** clause, you would replace the Http value assigned made to **filename=** with a full path string like *C:\myfile.xel*.
502
+
- In the **CREATE EVENT SESSION** statement, in its **ADD TARGET** clause, you would replace the Http value assigned made to **filename=** with a full path string like `C:\myfile.xel`.
507
503
508
504
- No Azure Storage account need be involved.
509
505
510
-
## More information
506
+
## Next steps
511
507
512
508
For more info about accounts and containers in the Azure Storage service, see:
0 commit comments