Skip to content

Blueprint module updates: remove operation and help message updates #8959

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

Merged
merged 4 commits into from
Apr 10, 2019
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
4 changes: 3 additions & 1 deletion src/Blueprint/Blueprint/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- Additional information about change #1
-->
## Upcoming Release
* Update Remove- cmdlet to not require SubscriptionId parameter
* Update cmdlet examples

## Version 0.1.0
* Preview release of Az.Blueprint module
* Preview release of Az.Blueprint module
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace Microsoft.Azure.Commands.Blueprint.Cmdlets
public class RemoveAzureRmBlueprintAssignment : BlueprintCmdletBase
{
#region Parameters
[Parameter(ParameterSetName = ParameterSetNames.DeleteBlueprintAssignmentByObject, Position = 0, Mandatory = true, ValueFromPipeline = true, HelpMessage = ParameterHelpMessages.AssignmentSubscriptionId)]
[Parameter(ParameterSetName = ParameterSetNames.DeleteBlueprintAssignmentByName, Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = ParameterHelpMessages.AssignmentSubscriptionId)]
[Parameter(ParameterSetName = ParameterSetNames.DeleteBlueprintAssignmentByObject, Position = 0, Mandatory = false, ValueFromPipeline = true, HelpMessage = ParameterHelpMessages.AssignmentSubscriptionId)]
[Parameter(ParameterSetName = ParameterSetNames.DeleteBlueprintAssignmentByName, Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = ParameterHelpMessages.AssignmentSubscriptionId)]
[ValidateNotNullOrEmpty]
public string SubscriptionId { get; set; }

Expand All @@ -48,14 +48,16 @@ public class RemoveAzureRmBlueprintAssignment : BlueprintCmdletBase
#region Cmdlet Overrides
public override void ExecuteCmdlet()
{
var subscription = SubscriptionId ?? DefaultContext.Subscription.Id;

try
{
switch (ParameterSetName)
{
case ParameterSetNames.DeleteBlueprintAssignmentByName:
if (ShouldProcess(SubscriptionId, string.Format(Resources.DeleteAssignmentShouldProcessString, Name)))
if (ShouldProcess(subscription, string.Format(Resources.DeleteAssignmentShouldProcessString, Name)))
{
var deletedAssignment = BlueprintClient.DeleteBlueprintAssignment(Utils.GetScopeForSubscription(SubscriptionId), Name);
var deletedAssignment = BlueprintClient.DeleteBlueprintAssignment(Utils.GetScopeForSubscription(subscription), Name);

if (deletedAssignment != null && PassThru.IsPresent)
{
Expand All @@ -64,7 +66,7 @@ public override void ExecuteCmdlet()
}
break;
case ParameterSetNames.DeleteBlueprintAssignmentByObject:
if (ShouldProcess(SubscriptionId, string.Format(Resources.DeleteAssignmentShouldProcessString, InputObject.Name)))
if (ShouldProcess(subscription, string.Format(Resources.DeleteAssignmentShouldProcessString, InputObject.Name)))
{
var deletedAssignment = BlueprintClient.DeleteBlueprintAssignment(InputObject.Scope, InputObject.Name);

Expand Down
4 changes: 2 additions & 2 deletions src/Blueprint/Blueprint/help/New-AzBlueprintAssignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PS C:\> $blueprintObject = Get-AzBlueprint -SubscriptionId "00000000-1111-0000-
PS C:\> New-AzBlueprintAssignment -Name "myAssignment" -Blueprint $blueprintObject -SubscriptionId "00000000-1111-0000-1111-000000000000" -Location "West US" -ResourceGroupParameter $rg -Parameter $params

Name : myAssignment
Id : /subscriptions/00000000-1111-0000-1111-000000000000/providers/Microsoft.Blueprint/blueprintAssignments/Assignment-PS-BlueprintDefinition
Id : /subscriptions/00000000-1111-0000-1111-000000000000/providers/Microsoft.Blueprint/blueprintAssignments/myAssignment
Scope : /subscriptions/00000000-1111-0000-1111-000000000000
LastModified : 2019-01-08
LockMode : None
Expand All @@ -45,7 +45,7 @@ Create a new blueprint assignment of the blueprint definition `$blueprintObject`

### Example 2
```powershell
PS C:\> New-AzBlueprintAssignment -Name "myAssignment" -Blueprint $blueprintObject -SubscriptionId 00000000-1111-0000-1111-000000000000 -Location "West US" -Parameter @{P1="v1"; P2="v2"} -Lock AllResources
PS C:\> New-AzBlueprintAssignment -Name "myAssignment" -Blueprint $blueprintObject -SubscriptionId 00000000-1111-0000-1111-000000000000 -Location "West US" -Parameter @{P1="v1"; P2="v2"} -Lock AllResourcesReadOnly
```

Create a new blueprint assignment of the blueprint definition `$blueprintObject` within the specified subscription using the defined parameter and resource group dictionary and configuring resource locking to **AllResources**. Defaults to using system-assigned identity. The location defines the region for creating the managed identity.
Expand Down