Skip to content

Commit bb3f6f0

Browse files
committed
Enable streaming from Azure Sql DB
1 parent 2b7efa5 commit bb3f6f0

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

SharedAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
// You can specify all the values or you can default the Build and Revision Numbers
3030
// by using the '*' as shown below:
3131
// [assembly: AssemblyVersion("1.0.*")]
32-
[assembly: AssemblyVersion("1.7.1")]
33-
[assembly: AssemblyFileVersion("1.7.1")]
32+
[assembly: AssemblyVersion("1.7.2")]
33+
[assembly: AssemblyFileVersion("1.7.2")]

WorkloadTools/Consumer/Analysis/WorkloadAnalyzer.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using WorkloadTools.Util;
1414
using System.Collections.Concurrent;
1515
using FastMember;
16+
using Microsoft.SqlServer.Management.SqlParser.SqlCodeDom;
1617

1718
namespace WorkloadTools.Consumer.Analysis
1819
{
@@ -1126,8 +1127,14 @@ protected void CreateTargetDatabase()
11261127

11271128
try
11281129
{
1129-
using (var conn = new SqlConnection())
1130+
var databaseName = ConnectionInfo.DatabaseName;
1131+
using (var conn = new SqlConnection())
11301132
{
1133+
// create a new connection to the target server
1134+
// for the analysis database, on the master db
1135+
// then create the target database if not available
1136+
var ci = new SqlConnectionInfo(ConnectionInfo);
1137+
ci.DatabaseName = "master";
11311138
conn.ConnectionString = ConnectionInfo.ConnectionString();
11321139
conn.Open();
11331140

@@ -1147,11 +1154,9 @@ IF DB_ID(@name) IS NULL
11471154
}
11481155
}
11491156
}
1150-
finally
1151-
{
1152-
// restore original database name
1153-
ConnectionInfo.DatabaseName = databaseName;
1154-
}
1157+
catch(Exception e) {
1158+
logger.Warn("Unable to create the target database for the analysisy", e.Message);
1159+
}
11551160

11561161
}
11571162

WorkloadTools/Listener/ExtendedEvents/ExtendedEventsWorkloadListener.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ public override void Initialize()
6161

6262
if (serverType == ServerType.AzureSqlDatabase)
6363
{
64-
if (FileTargetPath == null)
65-
{
66-
throw new ArgumentException("Azure SqlDatabase does not support Extended Events streaming. Please specify a path for the FileTarget");
67-
}
6864
if (ConnectionInfo.DatabaseName == null)
6965
{
7066
throw new ArgumentException("Azure SqlDatabase does not support starting Extended Events sessions on the master database. Please specify a database name.");
@@ -280,7 +276,7 @@ private void ReadEvents()
280276
try
281277
{
282278

283-
if (serverType != ServerType.AzureSqlDatabase && FileTargetPath == null)
279+
if (FileTargetPath == null)
284280
{
285281
reader = new StreamXEventDataReader(ConnectionInfo.ConnectionString(), SessionName, Events);
286282
}

WorkloadTools/SqlConnectionInfo.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ public class SqlConnectionInfo
1919
public int MaxPoolSize { get; set; } = 500;
2020
public Dictionary<string, string> DatabaseMap { get; set; } = new Dictionary<string, string>();
2121

22+
23+
public SqlConnectionInfo() { }
24+
25+
public SqlConnectionInfo(SqlConnectionInfo info)
26+
{
27+
this.ServerName = info.ServerName;
28+
this.DatabaseName = info.DatabaseName;
29+
this.SchemaName = info.SchemaName;
30+
this.UseIntegratedSecurity = info.UseIntegratedSecurity;
31+
this.UserName = info.UserName;
32+
this.Password = info.Password;
33+
this.Encrypt = info.Encrypt;
34+
this.TrustServerCertificate = info.TrustServerCertificate;
35+
this.ApplicationName = info.ApplicationName;
36+
this.MaxPoolSize = info.MaxPoolSize;
37+
this.DatabaseMap = info.DatabaseMap;
38+
}
39+
2240
public string ConnectionString()
2341
{
2442
return ConnectionString(ApplicationName);

0 commit comments

Comments
 (0)