Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected override ManagedInstanceAdvancedDataSecurityPolicyModel GetEntity()
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override SqlAdvancedThreatProtectionAdapter InitModelAdapter(IAzureSubscription subscription)
protected override SqlAdvancedThreatProtectionAdapter InitModelAdapter()
{
return new SqlAdvancedThreatProtectionAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ protected override ServerAdvancedThreatProtectionPolicyModel GetEntity()
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override SqlAdvancedThreatProtectionAdapter InitModelAdapter(IAzureSubscription subscription)
protected override SqlAdvancedThreatProtectionAdapter InitModelAdapter()
{
return new SqlAdvancedThreatProtectionAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class SqlAdvancedThreatProtectionAdapter
public SqlAdvancedThreatProtectionAdapter(IAzureContext context)
{
Context = context;
Subscription = context.Subscription;
Subscription = context?.Subscription;
SqlThreatDetectionAdapter = new SqlThreatDetectionAdapter(Context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ public abstract class AzureSqlDatabaseAdvisorCmdletBase : AzureSqlCmdletBase<IEn
/// <summary>
/// Initializes the model adapter
/// </summary>
/// <param name="subscription">The subscription the cmdlets are operation under</param>
/// <returns>The advisor adapter</returns>
protected override AzureSqlDatabaseAdvisorAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDatabaseAdvisorAdapter InitModelAdapter()
{
return new AzureSqlDatabaseAdvisorAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ public abstract class AzureSqlElasticPoolAdvisorCmdletBase : AzureSqlCmdletBase<
/// <summary>
/// Initializes the model adapter
/// </summary>
/// <param name="subscription">The subscription the cmdlets are operation under</param>
/// <returns>The advisor adapter</returns>
protected override AzureSqlElasticPoolAdvisorAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlElasticPoolAdvisorAdapter InitModelAdapter()
{
return new AzureSqlElasticPoolAdvisorAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ public abstract class AzureSqlServerAdvisorCmdletBase : AzureSqlCmdletBase<IEnum
/// <summary>
/// Initializes the model adapter
/// </summary>
/// <param name="subscription">The subscription the cmdlets are operation under</param>
/// <returns>The advisor adapter</returns>
protected override AzureSqlServerAdvisorAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlServerAdvisorAdapter InitModelAdapter()
{
return new AzureSqlServerAdvisorAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public class AzureSqlAdvisorCommunicatorBase
public AzureSqlAdvisorCommunicatorBase(IAzureContext context)
{
Context = context;
if (context.Subscription != Subscription)
if (context?.Subscription != Subscription)
{
Subscription = context.Subscription;
Subscription = context?.Subscription;
SqlClient = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ protected override DatabaseBlobAuditingSettingsModel GetEntity()
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override SqlAuditAdapter InitModelAdapter(IAzureSubscription subscription)
protected override SqlAuditAdapter InitModelAdapter()
{
return new SqlAuditAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ protected override ServerBlobAuditingSettingsModel GetEntity()
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override SqlAuditAdapter InitModelAdapter(IAzureSubscription subscription)
protected override SqlAuditAdapter InitModelAdapter()
{
return new SqlAuditAdapter(DefaultProfile.DefaultContext);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Sql/Sql/Auditing/Cmdlet/SqlDatabaseAuditingCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ protected override AuditingPolicyModel GetEntity()
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override SqlAuditAdapter InitModelAdapter(IAzureSubscription subscription)
protected override SqlAuditAdapter InitModelAdapter()
{
return new SqlAuditAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ protected override AuditingPolicyModel GetEntity()
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override SqlAuditAdapter InitModelAdapter(IAzureSubscription subscription)
protected override SqlAuditAdapter InitModelAdapter()
{
return new SqlAuditAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public class AuditingEndpointsCommunicator
public AuditingEndpointsCommunicator(IAzureContext context)
{
Context = context;
if (context.Subscription != Subscription)
if (context?.Subscription != Subscription)
{
Subscription = context.Subscription;
Subscription = context?.Subscription;
LegacySqlClient = null;
SqlClient = null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sql/Sql/Auditing/Services/SqlAuditAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class SqlAuditAdapter
public SqlAuditAdapter(IAzureContext context)
{
Context = context;
Subscription = context.Subscription;
Subscription = context?.Subscription;
Communicator = new AuditingEndpointsCommunicator(Context);
AzureCommunicator = new AzureEndpointsCommunicator(Context);
IgnoreStorage = false;
Expand Down
1 change: 1 addition & 0 deletions src/Sql/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->
## Upcoming Release
* Add Get/Set AzSqlDatabaseBackupShortTermRetentionPolicy
* Fix issue where not being logged into Azure account would result in nullref exception when executing SQL cmdlets

## Version 1.1.0
* Update incorrect online help URLs
Expand Down
4 changes: 2 additions & 2 deletions src/Sql/Sql/Common/AzureEndpointsCommunicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public class AzureEndpointsCommunicator
public AzureEndpointsCommunicator(IAzureContext context)
{
Context = context;
if (context.Subscription != Subscription)
if (context?.Subscription != Subscription)
{
Subscription = context.Subscription;
Subscription = context?.Subscription;
ResourcesClient = null;
StorageV2Client = null;
}
Expand Down
5 changes: 2 additions & 3 deletions src/Sql/Sql/Common/AzureSqlCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ protected virtual string GetResourceId(M model)
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected abstract A InitModelAdapter(IAzureSubscription subscription);
protected abstract A InitModelAdapter();

/// <summary>
/// Transforms the given model object to be an object that is written out
Expand All @@ -119,7 +118,7 @@ protected virtual string GetConfirmActionProcessMessage()
/// </summary>
public override void ExecuteCmdlet()
{
ModelAdapter = InitModelAdapter(DefaultProfile.DefaultContext.Subscription);
ModelAdapter = InitModelAdapter();
M model = GetEntity();
M updatedModel = ApplyUserInputToModel(model);
M responseModel = default(M);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ protected override DatabaseDataMaskingPolicyModel GetEntity()
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override SqlDataMaskingAdapter InitModelAdapter(IAzureSubscription subscription)
protected override SqlDataMaskingAdapter InitModelAdapter()
{
return new SqlDataMaskingAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ protected override IEnumerable<DatabaseDataMaskingRuleModel> PersistChanges(IEnu
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override SqlDataMaskingAdapter InitModelAdapter(IAzureSubscription subscription)
protected override SqlDataMaskingAdapter InitModelAdapter()
{
return new SqlDataMaskingAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public class DataMaskingEndpointsCommunicator
public DataMaskingEndpointsCommunicator(IAzureContext context)
{
Context = context;
if (context.Subscription != Subscription)
if (context?.Subscription != Subscription)
{
Subscription = context.Subscription;
Subscription = context?.Subscription;
SqlClient = null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sql/Sql/Data Masking/Services/SqlDataMaskingAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class SqlDataMaskingAdapter
public SqlDataMaskingAdapter(IAzureContext context)
{
Context = context;
Subscription = context.Subscription;
Subscription = context?.Subscription;
Communicator = new DataMaskingEndpointsCommunicator(Context);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Sql/Sql/Data Sync/Cmdlet/AzureSqlSyncAgentCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ public abstract class AzureSqlSyncAgentCmdletBase : AzureSqlCmdletBase<IEnumerab
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The Azure Subscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override AzureSqlDataSyncAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDataSyncAdapter InitModelAdapter()
{
return new AzureSqlDataSyncAdapter(DefaultProfile.DefaultContext);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Sql/Sql/Data Sync/Cmdlet/AzureSqlSyncGroupCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ public abstract class AzureSqlSyncGroupCmdletBase : AzureSqlDatabaseCmdletBase<I
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The Azure Subscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override AzureSqlDataSyncAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDataSyncAdapter InitModelAdapter()
{
return new AzureSqlDataSyncAdapter(DefaultProfile.DefaultContext);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Sql/Sql/Data Sync/Cmdlet/AzureSqlSyncMemberCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ public abstract class AzureSqlSyncMemberCmdletBase : AzureSqlDatabaseCmdletBase<
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The Azure Subscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override AzureSqlDataSyncAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDataSyncAdapter InitModelAdapter()
{
return new AzureSqlDataSyncAdapter(DefaultProfile.DefaultContext);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Sql/Sql/Data Sync/Cmdlet/AzureSqlSyncSchemaCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ public abstract class AzureSqlSyncSchemaCmdletBase : AzureSqlDatabaseCmdletBase<
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The Azure Subscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override AzureSqlDataSyncAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDataSyncAdapter InitModelAdapter()
{
return new AzureSqlDataSyncAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ public class GetAzureSqlSyncAgentSqlServerDatabase : AzureSqlCmdletBase<IEnumera
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override AzureSqlDataSyncAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDataSyncAdapter InitModelAdapter()
{
return new AzureSqlDataSyncAdapter(DefaultProfile.DefaultContext);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Sql/Sql/Data Sync/Cmdlet/GetAzureSqlSyncGroupLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ public class GetAzureSqlSyncGroupLog : AzureSqlDatabaseCmdletBase<IEnumerable<Az
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The Azure Subscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override AzureSqlDataSyncAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDataSyncAdapter InitModelAdapter()
{
return new AzureSqlDataSyncAdapter(DefaultProfile.DefaultContext);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Sql/Sql/Data Sync/Cmdlet/NewAzureSqlSyncAgentKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ public class NewAzureSqlSyncAgentKey : AzureSqlCmdletBase<IEnumerable<AzureSqlSy
/// <summary>
/// Creation and initialization of the ModelAdapter object
/// </summary>
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
/// <returns>An initialized and ready to use ModelAdapter object</returns>
protected override AzureSqlDataSyncAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDataSyncAdapter InitModelAdapter()
{
return new AzureSqlDataSyncAdapter(DefaultProfile.DefaultContext);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sql/Sql/Data Sync/Services/AzureSqlDataSyncAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class AzureSqlDataSyncAdapter
public AzureSqlDataSyncAdapter(IAzureContext context)
{
Context = context;
_subscription = context.Subscription;
_subscription = context?.Subscription;
Communicator = new AzureSqlDataSyncCommunicator(Context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public class AzureSqlDataSyncCommunicator
public AzureSqlDataSyncCommunicator(IAzureContext context)
{
Context = context;
if (context.Subscription != Subscription)
if (context?.Subscription != Subscription)
{
Subscription = context.Subscription;
Subscription = context?.Subscription;
LegacySqlClient = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ public abstract class AzureSqlDatabaseActivationCmdletBase
/// <summary>
/// Initializes the adapter
/// </summary>
/// <param name="subscription"></param>
/// <returns></returns>
protected override AzureSqlDatabaseActivationAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDatabaseActivationAdapter InitModelAdapter()
{
return new AzureSqlDatabaseActivationAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public class AzureSqlDatabaseActivationAdapter
/// </summary>
public IAzureContext Context { get; set; }

/// <summary>
/// Gets or sets the Azure Subscription
/// </summary>
private IAzureSubscription _subscription { get; set; }

/// <summary>
/// Constructs a database activation adapter
/// </summary>
Expand All @@ -48,7 +43,6 @@ public class AzureSqlDatabaseActivationAdapter
public AzureSqlDatabaseActivationAdapter(IAzureContext context)
{
Context = context;
_subscription = context.Subscription;
Communicator = new AzureSqlDatabaseActivationCommunicator(Context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public class AzureSqlDatabaseActivationCommunicator
public AzureSqlDatabaseActivationCommunicator(IAzureContext context)
{
Context = context;
if (context.Subscription != Subscription)
if (context?.Subscription != Subscription)
{
Subscription = context.Subscription;
Subscription = context?.Subscription;
SqlClient = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ public abstract class AzureSqlDatabaseBackupLongTermRetentionPolicyCmdletBase :
/// <summary>
/// Initializes the adapter
/// </summary>
/// <param name="subscription">The subscription to operate on</param>
/// <returns></returns>
protected override AzureSqlDatabaseBackupAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDatabaseBackupAdapter InitModelAdapter()
{
return new AzureSqlDatabaseBackupAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ public abstract class AzureSqlDatabaseBackupShortTermRetentionPolicyCmdletBase :
/// <summary>
/// Initializes the adapter
/// </summary>
/// <param name="subscription">The subscription to operate on</param>
/// <returns></returns>
protected override AzureSqlDatabaseBackupAdapter InitModelAdapter(IAzureSubscription subscription)
protected override AzureSqlDatabaseBackupAdapter InitModelAdapter()
{
return new AzureSqlDatabaseBackupAdapter(DefaultProfile.DefaultContext);
}
Expand Down
Loading