-
Notifications
You must be signed in to change notification settings - Fork 4k
V2A AAD Changes #4843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V2A AAD Changes #4843
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm some comments that need to be addressed
In addition, please make sure of the following:
-
You have updated the RecoveryServices.SiteRecovery change log with information about the changes being made in this PR
-
You have enabled all three piping scenarios (where applicable) to the New/Remove/Set/Start/Stop/Update, etc cmdlets (I left a comment for this one somewhere in the PR)
-
Please cleanup the commits in this PR so that it is easier to review for both sides. I would split them up so one commit has test changes, one has the test json files, one has the new cmdlets, and another has miscellaneous updates made. You can read about how to update your commits here
@@ -12,7 +12,7 @@ | |||
# RootModule = '' | |||
|
|||
# Version number of this module. | |||
ModuleVersion = '0.1.6' | |||
ModuleVersion = '0.1.5' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm looks like a bad merge caused some unnecessary changes in this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to 0.1.6
FileAccess.Read, | ||
FileShare.Read)) | ||
{ | ||
if (File.ReadAllText(this.vaultSettingsFilePath).ToLower().Contains("<asrvaultcreds")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm to read from/write to files, use DataStore.ReadFromFileStream()
from in the FileUtilities
class in Commands.Common
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used FileUtilities.DataStore.ReadFileAsText method
/// <summary> | ||
/// Sets Azure Site Revcovery Notification / Alert. | ||
/// </summary> | ||
[Cmdlet( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm it looks like you're missing the SupportsShouldProcess
property in this cmdlt attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the miss . Added that again.
/// Gets or sets EmailSubscriptionOwner .Mail to subscription owner. | ||
/// </summary> | ||
[Parameter(ParameterSetName = ASRParameterSets.EmailToSubscriptionOwner, Mandatory = true)] | ||
public SwitchParameter EmailSubscriptionOwners { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm this should be renamed to EnableEmailSubscriptionOwners
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
VerbsCommon.Set)) | ||
{ | ||
base.ExecuteSiteRecoveryCmdlet(); | ||
if (this.ShouldProcess( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm why is there two calls to this.ShouldProcess
and base.ExecuteSiteRecoveryCmdlet
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
[Parameter(ParameterSetName = ASRParameterSets.ByParam)] | ||
[Parameter(ParameterSetName = ASRParameterSets.ByFabricId)] | ||
[ValidateNotNullOrEmpty] | ||
public ASRFabric Fabric { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm does Fabric
contain a FabricId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
/// Gets or sets Resource Id. | ||
/// </summary> | ||
[Parameter(ParameterSetName = ASRParameterSets.ByFabricId, Mandatory = true)] | ||
public string FabricId { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm what exactly is FabricId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Id of ASRFabric.
[Parameter(ParameterSetName = ASRParameterSets.ByParam)] | ||
[Parameter(ParameterSetName = ASRParameterSets.ByFabricId)] | ||
[ValidateNotNullOrEmpty] | ||
public DateTime StartTime { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm should there be a corresponding EndTime
parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already there . But reordered below StartTime to give better visibility.
/// Gets or sets Resource Id. | ||
/// </summary> | ||
[Parameter(ParameterSetName = ASRParameterSets.ByResourceId, Mandatory = true)] | ||
public string ResourceId { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm anywhere that you are using a ResourceId
parameter, it should have the property ValueFromPipelineByPropertyName = true
so users are able to pipe the result of Get/Find-AzureRmResource
to a cmdlet with a ResourceId
parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/// </summary> | ||
[Parameter(Mandatory = true, ValueFromPipeline = true)] | ||
[ValidateNotNullOrEmpty] | ||
public ASRFabric Fabric { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm parameter set for ResourceId
of Fabric being provided? Please make sure that all cmldets that should support piping have the following three scenarios enabled:
- By object - involves using an
InputObject
parameter that hasValueFromPipeline = true
- By resource id - involves using a
ResourceId
parameter that hasValueFromPipelineByPropertyName = true
- By command line - involves using a
Name
andResourceGroupName
parameter with no ability to accept its value from the pipeline; this is your default parameter set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First two scenario fits for ASR.
Getting the PSObject by Name and ResourceGroupName parameter is not possible in ASR Case we need additional parameter like vault , protection container etc on case to case basis.
Name is mainly server generated Id and hard to remember.
@viverm It looks like you haven't committed and pushed the changes you mention in your responses to review comments. |
Error during build https://azuresdkci.westus2.cloudapp.azure.com/job/powershell/322/console Saw similar error with other PR builds/ d:\workspace\powershell\src\ResourceManager\Common\Commands.ScenarioTests.ResourceManager.Common\EnvironmentSetupHelper.cs(427): error : Microsoft.Azure.Commands.Sql.Test.ScenarioTests.VirtualNetworkRuleTest.TestVirtualNetworkRuleRemove [FAIL] [d:\workspace\powershell\build.proj] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm a few additional comments
I kicked off an on-demand job, and I suspect that StaticAnalysis will fail from the breaking change tool and/or signature verifier. If so, please check the Build Artifacts of the job, and look for the severity 0 or 1 exceptions in the BreakingChangeIssues.csv
and/or SignatureIssues.csv
files
@@ -170,7 +231,7 @@ PrivateData = @{ | |||
Tags = 'Azure','ResourceManager','ARM','SiteRecovery' | |||
|
|||
# A URL to the license for this module. | |||
LicenseUri = 'https://aka.ms/azps-license' | |||
LicenseUri = 'https://raw.githubusercontent.com/Azure/azure-powershell/preview/LICENSE.txt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm please revert this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -153,7 +155,7 @@ public static string GetDefaultPath() | |||
throw new Exception("Invalid ARM ID"); | |||
} | |||
|
|||
for (var i = 1; i < armFields.Length; i = i + 2) | |||
for (var i = 0; i < armFields.Length; i = i + 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm shouldn't this always fail with an IndexOutOfRangeException
?
For example, if armFields
has five elements, this loop will get the following elements:
i == 0
: 1st (idx 0) and 2nd (idx 1)
i == 2
: 3rd (idx 2) and 4th (idx 3)
i == 4
: 5th (idx 4) and 6th (idx 5 DOESN'T EXIST!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we were expecting things in pair like 1st will be the 2nd the value .
We are using the other utility method to get the value .this call is not used anymore .
Marked this as part of cleanup activity,
@@ -75,25 +76,28 @@ public override void ExecuteSiteRecoveryCmdlet() | |||
{ | |||
using (var powerShell = System.Management.Automation.PowerShell.Create()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm if the powerShell
object is not being used anymore, we should remove the using
@@ -148,6 +148,20 @@ public override void ExecuteSiteRecoveryCmdlet() | |||
VmId = ((HyperVReplicaBlueReplicationDetails)item | |||
.Properties.ProviderSpecificDetails).VmId; | |||
} | |||
else if (item.Properties.ProviderSpecificDetails | |||
.GetType() == |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm nit: for the lines where .GetType()
is by itself, can you tab it to be consistent with the other instances of it above
It looks like this is also the case in NewAzureRmRecoveryServicesAsrRecoveryPlan.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm a few minor questions, otherwise LGTM
[Parameter(ParameterSetName = ASRParameterSets.ByParam)] | ||
[Parameter(ParameterSetName = ASRParameterSets.ByFabricId)] | ||
[ValidateNotNullOrEmpty] | ||
public ASRFabric Fabric { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm raising this again - if a Fabric
has a FabricId
, why does the user need to provide one? It seems like you're just using it to get the Name
of the fabric, but you already receive the name from the mandatory Fabric
parameter that a user would pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make is mutually exclusive and break in two paramset. If the user has fabricId or fabricObject he can directly call it.
/// <summary> | ||
/// ProcessRecord of the command. | ||
/// </summary> | ||
public override void ExecuteSiteRecoveryCmdlet() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm can we add a parameter set that allows users to provide a Fabric
and Name
? This will be the default parameter set that will take care of the command line scenario and is similar to what is done with the Get-AsrVCenter
cmdlet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.
if (this.ShouldProcess(vCenterName, VerbsCommon.Remove)) | ||
{ | ||
var response = this.RecoveryServicesClient.RemoveAzureRmSiteRecoveryvCenter( | ||
fabricName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viverm just a general question for cmdlets that have a Fabric
parameter (and this might have been discussed already): why don't we make the user provide a FabricName
parameter instead of the entire object? That way, they don't have to get the Fabric
object each time they want to run these cmdlets and can just provide a string instead. Is the FabricName
hard to discover for the user, or difficult to remember?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fabric Name is ASR generated id which is unique . It is Difficult for user to remember and pass it. user will store and pass it so he can fabric object like he is doing in other cmdlets.
Description
This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.
General Guidelines
Testing Guidelines
Cmdlet Signature Guidelines
ShouldProcess
and haveSupportShouldProcess=true
specified in the cmdlet attribute. You can find more information onShouldProcess
here.OutputType
attribute if any output is produced - if the cmdlet produces no output, it should implement aPassThru
parameter.Cmdlet Parameter Guidelines