Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 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
75 changes: 75 additions & 0 deletions .github/agents/ps-cmdlet.agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
name: PowerShell Pull Request Agent
description: Specialized agent for creating PowerShell pull requests based on a design request
---

The user is going to ask you to implement a new feature in existing C# code for a Powershell cmdlet. You will write tests, make code changes, add help docs, and add changelog.
You are an engineering assistant helping Azure PowerShell contributors update or add parameters to Compute cmdlets. Your job is to accurately locate the cmdlet implementation, modify parameters and execution flow, apply PowerShell/ComputeRP conventions, and produce all required artifacts (code, docs, tests, and changelog). Prioritize correctness, least-risk edits, and traceability.

# Scope
- Module: Azure PowerShell Compute
- Cmdlet files live under `src/Compute/Compute/**`
- You will read and reason about C# cmdlet sources, strategy classes, model classes, and test assets

# Objectives
1) Identify the correct cmdlet file and confirm the cmdlet mapping.
2) Add or modify parameters with proper metadata and mapping.
3) Update all required files (code, help, tests, changelog).

# Ground Truth & Location Rules
- Primary cmdlet implementation: `src/Compute/Compute/…/<command>.cs`
- Example: `New-AzVM` → `NewAzureVMCommand.cs`
- Confirm mapping via `[Cmdlet("Verb", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "Noun", ...)]`
- Example: `[Cmdlet("New", AzureRMPrefix + "VM", …)]` ⇒ `New-AzVM`
- Related execution may be in associated strategy files (e.g., `VirtualMachineStrategy.cs`)
- Model classes representing Swagger schema live in: `src/Compute/Compute/Models/<command>.cs`

# Parameter Authoring Rules
- Parameters are usually declared at the top of the cmdlet C# file.
- Parameters have metadata that may specify parameter sets or `Mandatory` status.
- **Mapping requirement:** Variables in **PowerShell objects must have a `set`** method to be bound from parameters. Follow the structure of existing parameters
- Keep parameter names, types, and sets consistent with the cmdlet design

# Execution Flow Rules
- `ExecuteCmdlet()` implements logic per **parameter set** (usually via `switch`).
- `DefaultExecuteCmdlet()` handles **DefaultParameterSet**.
- Additional methods (e.g., `CreateConfigAsync()`) may be invoked directly or via a `*Strategy` file.
- **Editing a parameter set requires updating the full call stack**:
- For DefaultParameterSet ⇒ adjust `DefaultExecuteCmdlet()` path.
- For other sets ⇒ adjust their specific methods and any strategy indirections.
- Not all files will have these methods or follow this format, so use the existing patterns when adding new parameters.

# Built-in Utilities (apply exactly)
- Determine if a value was passed:
- `IsParameterBound(c => c.<ParameterName>)`

- If required details are missing, make a comment and request clarification from the owning team.

# Required Artifacts to Update
1) **Changelog**
- `src/Compute/Compute/ChangeLog.md`
- Describe customer-visible changes (new parameter, behavior change, etc.).
2) **Model Class** (Swagger mapping)
- `src/Compute/Compute/Models/<model>.cs`
- Add/adjust properties to represent the API schema.
3) **Cmdlet Implementation**
- `src/Compute/Compute/<usually Generated or Manual or Strategies>/…/<command>.cs`
- Add/modify parameters, validation, binding, and execution paths.
- If code is split, also update related files (e.g., `NewAzureVMCommand.cs`, `VirtualMachineStrategy.cs`).
4) **Help Content**
- `src/Compute/Compute/help/<command>.md`
- Regenerate using the module's help script: Update-MarkdownHelp -Path ./src/Compute/Compute/help/New-AzVM.md -AlphabeticParamsOrder -UseFullTypeName
- Ensure examples cover new parameters.
5) **Tests**
- PowerShell scenario test: `src/Compute/Compute.Test/ScenarioTests/<command>.ps1`
- C# test reference: `src/Compute/Compute.Test/ScenarioTests/<command>.cs`
- Add cases for: presence/absence of the new parameter, parameter set routing, validation, and expected side effects. Use existing tests for reference on how to create new tests.

# Quality & Safety Checklist (enforce before finalizing)
- Cmdlet attribute matches `<Verb>-Az<Noun>` and correct parameter sets.
- New/changed parameters have clear `Parameter` metadata (sets, `Mandatory`, `HelpMessage` if applicable).
- `ExecuteCmdlet()` routes correctly; Default vs non-default paths updated.
- `IsParameterBound` used to detect passed values; no reliance on null for "not provided".
- Help regenerated and examples verified.
- Scenario tests cover success/failure paths.
- `ChangeLog.md` describes customer-visible impact.
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ function Test-VirtualMachineScaleSet-Common($IsManaged)

Write-Verbose($output);
Assert-True { $output.Contains("PlatformUpdateDomain") };

Write-Verbose ('Running Command : ' + 'Get-AzVmssVM -ResiliencyView');
$vmResiliency = Get-AzVmssVM -ResiliencyView -ResourceGroupName $rgname -VMScaleSetName $vmssName -InstanceId $i;
Assert-NotNull $vmResiliency;
$output = $vmResiliency | Out-String;
Write-Verbose($output);
# ResilientVMDeletionStatus property should be present in the output when ResiliencyView is used
}

$st = $vmssResult | Stop-AzVmss -StayProvision -Force;
Expand Down
4 changes: 4 additions & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

-->
## Upcoming Release
* Added `-ResiliencyView` parameter to `Get-AzVmssVM` cmdlet
- Retrieves the resilient VM deletion status for Virtual Machine Scale Set (VMSS) VMs
- Indicates whether automatic delete retries are in progress, failed, or not started
- Supports monitoring the real-time status of the Resilient Delete feature

## Version 11.0.0
* Improved user experience and consistency. This may introduce breaking changes. Please refer to [here](https://go.microsoft.com/fwlink/?linkid=2340249).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public string ResourceGroupName
public string Location { get; set; }
public IDictionary<string, string> Tags { get; set; }
public string UserData { get; set; }
public string ResilientVMDeletionStatus { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public partial class GetAzureRmVmssVM : ComputeAutomationBaseCmdlet
protected const string DefaultParameterSet = "DefaultParameter",
FriendMethodParameterSet = "FriendMethod";
private VmssVMInstanceViewTypes UserDataExpand = VmssVMInstanceViewTypes.UserData;
private VmssVMInstanceViewTypes ResiliencyViewExpand = VmssVMInstanceViewTypes.ResiliencyView;

public override void ExecuteCmdlet()
{
Expand All @@ -58,7 +59,14 @@ public override void ExecuteCmdlet()
ComputeAutomationAutoMapperProfile.Mapper.Map<VirtualMachineScaleSetVMInstanceView, PSVirtualMachineScaleSetVMInstanceView>(result, psObject);
WriteObject(psObject);
}
else if (this.UserData == true)
else if (this.ResiliencyView.IsPresent)
{
var result = VirtualMachineScaleSetVMsClient.Get(resourceGroupName, vmScaleSetName, instanceId, ResiliencyViewExpand);
var psObject = new PSVirtualMachineScaleSetVM();
ComputeAutomationAutoMapperProfile.Mapper.Map<VirtualMachineScaleSetVM, PSVirtualMachineScaleSetVM>(result, psObject);
WriteObject(psObject);
}
else if (this.UserData.IsPresent)
{
var result = VirtualMachineScaleSetVMsClient.Get(resourceGroupName, vmScaleSetName, instanceId, UserDataExpand);
var psObject = new PSVirtualMachineScaleSetVM();
Expand Down Expand Up @@ -173,5 +181,17 @@ public override void ExecuteCmdlet()
HelpMessage = "UserData for the Vmss, which will be Base64 encoded. Customer should not pass any secrets in here.",
ValueFromPipelineByPropertyName = true)]
public SwitchParameter UserData { get; set; }

[Parameter(
Mandatory = false,
ParameterSetName = DefaultParameterSet,
HelpMessage = "Gets the resilient VM deletion status for the VM, which indicates whether retries are in progress, failed, or not started.",
ValueFromPipelineByPropertyName = true)]
[Parameter(
Mandatory = false,
ParameterSetName = FriendMethodParameterSet,
HelpMessage = "Gets the resilient VM deletion status for the VM, which indicates whether retries are in progress, failed, or not started.",
ValueFromPipelineByPropertyName = true)]
public SwitchParameter ResiliencyView { get; set; }
}
}
30 changes: 27 additions & 3 deletions src/Compute/Compute/help/Get-AzVmssVM.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Gets the properties of a VMSS virtual machine.
### DefaultParameter (Default)
```
Get-AzVmssVM [[-ResourceGroupName] <String>] [[-VMScaleSetName] <String>] [[-InstanceId] <String>] [-UserData]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-ResiliencyView] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

### FriendMethod
```
Get-AzVmssVM [[-ResourceGroupName] <String>] [[-VMScaleSetName] <String>] [[-InstanceId] <String>]
[-InstanceView] [-UserData] [-DefaultProfile <IAzureContextContainer>]
[-InstanceView] [-UserData] [-ResiliencyView] [-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
```

Expand Down Expand Up @@ -59,6 +59,15 @@ This command gets the properties of the VMSS virtual machine named VMSS004 that
Since the command specifies the *InstanceView* switch parameter, the cmdlet gets the instance view of the virtual machine.
The command gets the instance ID stored in the variable $ID for which to get the instance view.

### Example 4: Get the resilient VM deletion status of a VMSS virtual machine
```powershell
Get-AzVmssVM -ResiliencyView -ResourceGroupName "Group001" -VMScaleSetName "VMSS001" -InstanceId "0"
```

This command gets the resilient VM deletion status for the VMSS virtual machine with instance ID 0 in the scale set VMSS001.
The ResiliencyView parameter retrieves the ResilientVMDeletionStatus property, which indicates whether automatic delete retries are in progress, failed, or not started.
This is useful for monitoring the Resilient Delete feature status.

## PARAMETERS

### -DefaultProfile
Expand Down Expand Up @@ -136,8 +145,23 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -ResiliencyView
Gets the resilient VM deletion status for the VM, which indicates whether retries are in progress, failed, or not started. This parameter is only supported when retrieving a specific VM instance (when InstanceId is provided).

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -VMScaleSetName
Species the name of the VMSS.
Specifies the name of the VMSS.

```yaml
Type: System.String
Expand Down