Skip to content

Commit e45c609

Browse files
committed
Fix static caching issue of SqlClient
1 parent 9241c6a commit e45c609

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/ResourceManager/Sql/Commands.Sql/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Fixed issue where some backup cmdlets would not recognize the current azure subscription
2122

2223
## Version 4.11.3
2324
* Fixed issue with default resource groups not being set.

src/ResourceManager/Sql/Commands.Sql/Database Backup/Services/AzureSqlDatabaseBackupCommunicator.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ public class AzureSqlDatabaseBackupCommunicator
3333
/// The Sql client to be used by this end points communicator
3434
/// </summary>
3535
private static Management.Sql.LegacySdk.SqlManagementClient LegacyClient { get; set; }
36-
/// <summary>
37-
/// The Sql client to be used by this end points communicator
38-
/// </summary>
39-
private static Management.Sql.SqlManagementClient SqlClient { get; set; }
4036

4137
/// <summary>
4238
/// The resources management client used by this communicator
@@ -400,11 +396,8 @@ private Management.Sql.LegacySdk.SqlManagementClient GetLegacySqlClient()
400396
private Management.Sql.SqlManagementClient GetCurrentSqlClient()
401397
{
402398
// Get the SQL management client for the current subscription
403-
if (SqlClient == null)
404-
{
405-
SqlClient = AzureSession.Instance.ClientFactory.CreateArmClient<Management.Sql.SqlManagementClient>(Context, AzureEnvironment.Endpoint.ResourceManager);
406-
}
407-
return SqlClient;
399+
// Note: client is not cached in static field because that causes ObjectDisposedException in functional tests.
400+
return AzureSession.Instance.ClientFactory.CreateArmClient<Management.Sql.SqlManagementClient>(Context, AzureEnvironment.Endpoint.ResourceManager);
408401
}
409402

410403
/// <summary>

0 commit comments

Comments
 (0)