Skip to content

Commit 0b2d429

Browse files
author
Hovsep
committed
Merge pull request #2079 from vivsriaus/ApiVersions
[Release.1.3.2] Change api-version for policy and locks
2 parents 20d3747 + 1a4473e commit 0b2d429

File tree

7 files changed

+34
-27
lines changed

7 files changed

+34
-27
lines changed

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/Constants.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ public static class Constants
5757
/// <summary>
5858
/// The default policy API version.
5959
/// </summary>
60-
public static readonly string PolicyApiVersion = "2015-10-01-preview";
60+
public static readonly string PolicyApiVersion = "2016-04-01";
61+
62+
/// <summary>
63+
/// The default Lock API version.
64+
/// </summary>
65+
public static readonly string LockApiVersion = "2015-01-01";
66+
67+
/// <summary>
68+
/// The default deployment operation API version.
69+
/// </summary>
70+
public static readonly string DeploymentOperationApiVersion = "2016-02-01";
6171

6272
/// <summary>
6373
/// The move action.

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ protected override void OnProcessRecord()
6262
this.SubscriptionId = DefaultContext.Subscription.Id;
6363
}
6464

65-
if(!string.IsNullOrEmpty(this.ApiVersion))
66-
{
67-
this.WriteWarning("The parameter ApiVersion in Get-AzureRmResourceGroupDeploymentOperation cmdlet is being deprecated and will be removed in a future release.");
68-
}
69-
7065
this.RunCmdlet();
7166
}
7267

@@ -89,9 +84,7 @@ private async Task<ResponseWithContinuation<JObject[]>> GetResources()
8984
{
9085
var resourceId = this.GetResourceId();
9186

92-
var apiVersion = await this
93-
.DetermineApiVersion(resourceId: resourceId)
94-
.ConfigureAwait(continueOnCapturedContext: false);
87+
var apiVersion = string.IsNullOrWhiteSpace(this.ApiVersion) ? Constants.DeploymentOperationApiVersion : this.ApiVersion;
9588

9689
return await this
9790
.GetResourcesClient()

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,11 @@ private async Task<JObject> GetResource()
8080
{
8181
var resourceId = this.GetResourceId(this.LockName);
8282

83-
var apiVersion = await this
84-
.DetermineApiVersion(resourceId: resourceId)
85-
.ConfigureAwait(continueOnCapturedContext: false);
86-
8783
return await this
8884
.GetResourcesClient()
8985
.GetResource<JObject>(
9086
resourceId: resourceId,
91-
apiVersion: apiVersion,
87+
apiVersion: this.LockApiVersion,
9288
cancellationToken: this.CancellationToken.Value)
9389
.ConfigureAwait(continueOnCapturedContext: false);
9490
}
@@ -100,10 +96,6 @@ private async Task<ResponseWithContinuation<JObject[]>> ListResourcesTypeCollect
10096
{
10197
var resourceCollectionId = this.GetResourceId(this.LockName);
10298

103-
var apiVersion = await this
104-
.DetermineApiVersion(resourceId: resourceCollectionId)
105-
.ConfigureAwait(continueOnCapturedContext: false);
106-
10799
var filter = this.AtScope
108100
? "$filter=atScope()"
109101
: null;
@@ -112,7 +104,7 @@ private async Task<ResponseWithContinuation<JObject[]>> ListResourcesTypeCollect
112104
.GetResourcesClient()
113105
.ListObjectColleciton<JObject>(
114106
resourceCollectionId: resourceCollectionId,
115-
apiVersion: apiVersion,
107+
apiVersion: this.LockApiVersion,
116108
cancellationToken: this.CancellationToken.Value,
117109
odataQuery: filter)
118110
.ConfigureAwait(continueOnCapturedContext: false);

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/NewAzureResourceLockCmdlet.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,20 @@ protected override void OnProcessRecord()
7474
resourceId,
7575
() =>
7676
{
77-
var apiVersion = this.DetermineApiVersion(resourceId: resourceId).Result;
7877
var resourceBody = this.GetResourceBody();
7978

8079
var operationResult = this.GetResourcesClient()
8180
.PutResource(
8281
resourceId: resourceId,
83-
apiVersion: apiVersion,
82+
apiVersion: this.LockApiVersion,
8483
resource: resourceBody,
8584
cancellationToken: this.CancellationToken.Value)
8685
.Result;
8786

8887
var managementUri = this.GetResourcesClient()
8988
.GetResourceManagementRequestUri(
9089
resourceId: resourceId,
91-
apiVersion: apiVersion);
90+
apiVersion: this.LockApiVersion);
9291

9392
var activity = string.Format("PUT {0}", managementUri.PathAndQuery);
9493
var result = this.GetLongRunningOperationTracker(activityName: activity, isResourceCreateOrUpdate: true)

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/RemoveAzureResourceLockCmdlet.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ protected override void OnProcessRecord()
5656
resourceId,
5757
() =>
5858
{
59-
var apiVersion = this.DetermineApiVersion(resourceId: resourceId).Result;
60-
6159
var operationResult = this.GetResourcesClient()
6260
.DeleteResource(
6361
resourceId: resourceId,
64-
apiVersion: apiVersion,
62+
apiVersion: this.LockApiVersion,
6563
cancellationToken: this.CancellationToken.Value)
6664
.Result;
6765

@@ -73,7 +71,7 @@ protected override void OnProcessRecord()
7371
var managementUri = this.GetResourcesClient()
7472
.GetResourceManagementRequestUri(
7573
resourceId: resourceId,
76-
apiVersion: apiVersion);
74+
apiVersion: this.LockApiVersion);
7775

7876
var activity = string.Format("DELETE {0}", managementUri.PathAndQuery);
7977

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public abstract class ResourceLockManagementCmdletBase : ResourceManagerCmdletBa
6565
/// <summary>
6666
/// Gets or sets the scope.
6767
/// </summary>
68-
[Alias("Id", "ResourceId")]
6968
[Parameter(ParameterSetName = ResourceLockManagementCmdletBase.ScopeLevelLock, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The scope. e.g. to specify a database '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaserName}', to specify a resoruce group: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'")]
7069
[ValidateNotNullOrEmpty]
7170
public string Scope { get; set; }
@@ -105,10 +104,21 @@ public abstract class ResourceLockManagementCmdletBase : ResourceManagerCmdletBa
105104
/// <summary>
106105
/// The Id of the lock.
107106
/// </summary>
107+
[Alias("Id", "ResourceId")]
108108
[Parameter(ParameterSetName = ResourceLockManagementCmdletBase.LockIdParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the lock.")]
109109
[ValidateNotNullOrEmpty]
110110
public string LockId { get; set; }
111111

112+
/// <summary>
113+
/// Determines the api version to be used
114+
/// </summary>
115+
public string LockApiVersion { get; set; }
116+
117+
public ResourceLockManagementCmdletBase()
118+
{
119+
this.LockApiVersion = string.IsNullOrWhiteSpace(this.ApiVersion) ? Constants.LockApiVersion : this.ApiVersion;
120+
}
121+
112122
/// <summary>
113123
/// Gets the resource Id from the supplied PowerShell parameters.
114124
/// </summary>

src/ResourceManager/Resources/Commands.Resources/ResourceGroupDeployments/NewAzureResourceGroupDeploymentCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public override void ExecuteCmdlet()
6363
DeploymentDebugLogLevel = GetDeploymentDebugLogLevel(DeploymentDebugLogLevel)
6464
};
6565

66+
if(!string.IsNullOrEmpty(parameters.DeploymentDebugLogLevel))
67+
{
68+
WriteWarning("The DeploymentDebug setting has been enabled. This can potentially log secrets like passwords used in resource property or listKeys operations when you retrieve the deployment operations through Get-AzureRmResourceGroupDeploymentOperation");
69+
}
70+
6671
if(this.Mode == DeploymentMode.Complete)
6772
{
6873
this.ConfirmAction(

0 commit comments

Comments
 (0)