-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Service Bus: some issues fix and piping for remove cmdlet #6732
Service Bus: some issues fix and piping for remove cmdlet #6732
Conversation
…nto preview_ipobject # Conflicts: # src/ResourceManager/ServiceBus/Commands.ServiceBus/help/Remove-AzureRmServiceBusNamespace.md # src/ResourceManager/ServiceBus/Commands.ServiceBus/help/Remove-AzureRmServiceBusQueue.md # src/ResourceManager/ServiceBus/Commands.ServiceBus/help/Remove-AzureRmServiceBusRule.md # src/ResourceManager/ServiceBus/Commands.ServiceBus/help/Remove-AzureRmServiceBusSubscription.md # src/ResourceManager/ServiceBus/Commands.ServiceBus/help/Remove-AzureRmServiceBusTopic.md
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.
@v-Ajnava some comments for you to take a look at
@@ -188,6 +188,7 @@ | |||
<None Include="SessionRecords\Microsoft.Azure.Commands.ServiceBus.Test.ScenarioTests.ServiceBusDRConfigurationTests\ServiceBusDRConfigurationsCURD.json"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</None> | |||
<None Include="SessionRecords\Microsoft.Azure.Commands.ServiceBus.Test.ScenarioTests.ServiceBusDRConfigurationTests\ServiceBusDRConfigurationsCURDAlterName.json" /> |
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.
@v-Ajnava you'll need to make sure this is copied to the output directory:
<None Include="SessionRecords\Microsoft.Azure.Commands.ServiceBus.Test.ScenarioTests.ServiceBusDRConfigurationTests\ServiceBusDRConfigurationsCURDAlterName.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
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.
Resolved
# Delete the created Topic | ||
$ResultDeleteTopic = Remove-AzureRmServiceBusTopic -ResourceGroupName $resourceGroupName -Namespace $namespaceName -Name $ResulListTopic[0].Name | ||
Assert-True {$ResultDeleteTopic} "Topic not deleted" | ||
## Delete the created Topic |
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.
@v-Ajnava please delete commented-out code (this applies everywhere in this PR)
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.
resolved
@@ -20,6 +20,8 @@ | |||
--> | |||
## Current Release | |||
* Updated help files to include full parameter types and correct input/output types. | |||
* Updated piping for InputObject and ResourceId in remove cmdlets | |||
* fixed few issues |
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.
@v-Ajnava would you mind adding a sub-bullet(s) that link to the issues fixed where applicable?
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.
resolved
switch (tokens.Length) | ||
{ | ||
case 2: | ||
ParentResource = tokens[1]; |
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.
@v-Ajnava what string is expected to be passed into this function? If it's a normal resource id (e.g., /subscription/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxxx/Microsoft.PROVIDER/PARENT1/xxxxxx/.....
), then wouldn't tokens[1]
be the subscription id?
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, its a resource id, but the tokens here will be the ParentResource property of ResourceIdentifier (Microsoft.Azure.Management.Internal.Resources.Utilities.Models) class. Tokens will have only parent resources.
/// <summary> | ||
/// The Service Bus Premium namespace throughput units. | ||
/// </summary> | ||
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, Position = 4, HelpMessage = "The Service Bus premium namespace throughput units, allowed values 1 or 2 or 4")] |
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.
@v-Ajnava please remove the Position
property from this 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.
resolved
// delete a Subscription | ||
if (ShouldProcess(target: Name, action: string.Format(Resources.RemoveSubscription, Name, Topic, Namespace))) | ||
{ | ||
WriteObject(Client.DeleteSubscription(ResourceGroupName, Namespace, Topic, Name)); |
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.
@v-Ajnava what was this operation returning before? We should make sure we are still writing the same type to the output stream
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.
resolved
namespace Microsoft.Azure.Commands.ServiceBus.Commands.Topic | ||
{ | ||
/// <summary> | ||
/// 'Remove-AzureRmServiceBusTopic' Cmdlet removes the specified ServiceBus Topic | ||
/// </summary> | ||
[Cmdlet(VerbsCommon.Remove, ServicebusTopicVerb , SupportsShouldProcess = true)] | ||
[Cmdlet(VerbsCommon.Remove, ServicebusTopicVerb, DefaultParameterSetName = TopicPropertiesParameterSet, SupportsShouldProcess = true)] |
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.
@v-Ajnava same comment about output type
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.
resolved
if (ShouldProcess(target: Name, action: string.Format(Resources.RemoveTopic, Name, Namespace))) | ||
{ | ||
WriteObject(Client.DeleteQueue(ResourceGroupName, Namespace, Name)); |
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.
@v-Ajnava same comment about what was previously being written to the output stream
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.
resolved
@@ -29,13 +42,46 @@ PS C:\> Remove-AzureRmServiceBusNamespace -ResourceGroup Default-ServiceBus-West | |||
|
|||
Removes the Service Bus namespace `SB-Example1` from the specified resource group `Default-ServiceBus-WestUS`. | |||
|
|||
### Example 2 - InputObject | |||
``` | |||
PS C:\> Remove-AzureRmServiceBusNamespace -InputObject $inputobject |
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.
@v-Ajnava for the examples where you are using -InputObject
, would you mind adding a line showing the user where they get value from?
PS C;\> $InputObject = Get-AzureRmServiceBusNamespace <params>
PS C:\> Remove-AzureRmServiceBusNamespace -InputObject $InputObject
or better yet, you could show the user the piping scenario we are trying to enable with this parameter set:
PS C:\> Get-AzureRmServiceBusNamespace <params> | Remove-AzureRmServiceBusNamespace
then you could provide a snippet below this example letting them know it binds the result of Get-AzureRmServiceBusNamespace
to the -InputObject
parameter of the Remove-AzureRmServiceBusNamespace
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.
resolved
|
||
### Example 3 - ResourceId | ||
``` | ||
PS C:\> Remove-AzureRmServiceBusNamespace -ResourceId $resourceid |
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.
@v-Ajnava similar comment to the one above for -InputObject
(and it also applies for the examples where you're using -ResourceId
)
Using a separate variable:
PS C:\> $ResourceId = (Get-AzureRmResource -ResourceType Microsoft.ServiceBus/namespaces).ResourceId
PS C:\> Remove-AzureRmServiceBusNamespace -ResourceId $ResourceId
Using piping:
PS C:\> Get-AzureRmResource -ResourceType Microsoft.ServiceBus/namespaces | Remove-AzureRmServiceBusNamespace
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.
resolved
…nto preview_ipobject # Conflicts: # src/ResourceManager/ServiceBus/Commands.ServiceBus/ChangeLog.md # src/ResourceManager/ServiceBus/Commands.ServiceBus/Cmdlets/Namespace/RemoveAzureServiceBusNamespace.cs # src/ResourceManager/ServiceBus/Commands.ServiceBus/Cmdlets/Queue/RemoveAzureServiceBusQueue.cs # src/ResourceManager/ServiceBus/Commands.ServiceBus/Cmdlets/Topic/RemoveAzureServiceBusTopic.cs # src/ResourceManager/ServiceBus/Commands.ServiceBus/help/Remove-AzureRmServiceBusNamespace.md
public string ResourceId { get; set; } | ||
|
||
[Parameter(Mandatory = false)] | ||
public SwitchParameter PassThru { 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.
@v-Ajnava it doesn't look like the -PassThru
parameter is being used anymore. I might have been a little unclear with the comment I made regarding this. I wanted to make sure that whatever was returned by the operation below was still being returned. You can still assign the result to a variable, and if the user provides -PassThru
, then you write that object to the output stream.
var result = Client.DeleteQueue(ResourceGroupName, Namespace, Name);
if (PassThru.IsPresent)
{
WriteObject(result);
}
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.
@v-Ajnava this comment applies to the other affected areas
@cormacpayne the test had failed, so re-recorded and pushed the recordings. the push dismissed your review. can you please review it? |
Description
added Piping scenario for remove cmdlets
fixed issues:
#4340
#3780
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 aPassThrough
parameter.Cmdlet Parameter Guidelines