Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ public class NewAzureAvailabilitySetCommand : AvailabilitySetBaseCmdlet
)]
public Hashtable Tag { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Specifies the API version to determine which scheduled events schema version will be delivered. Format: YYYY-MM-DD",
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string ScheduledEventsApiVersion { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Specifies if scheduled events should be auto-approved when all instances are down.",
ValueFromPipelineByPropertyName = true)]
public bool? EnableAllInstancesDown { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

Expand Down Expand Up @@ -116,6 +129,36 @@ public override void ExecuteCmdlet()
avSetParams.ProximityPlacementGroup = new SubResource(this.ProximityPlacementGroupId);
}

if (this.IsParameterBound(c => c.ScheduledEventsApiVersion))
{
if (avSetParams.ScheduledEventsPolicy == null)
{
avSetParams.ScheduledEventsPolicy = new ScheduledEventsPolicy();
}
if (avSetParams.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets == null)
{
avSetParams.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets = new ScheduledEventsAdditionalPublishingTargets();
}
if (avSetParams.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph == null)
{
avSetParams.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph = new EventGridAndResourceGraph();
}
avSetParams.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph.ScheduledEventsApiVersion = this.ScheduledEventsApiVersion;
}

if (this.IsParameterBound(c => c.EnableAllInstancesDown))
{
if (avSetParams.ScheduledEventsPolicy == null)
{
avSetParams.ScheduledEventsPolicy = new ScheduledEventsPolicy();
}
if (avSetParams.ScheduledEventsPolicy.AllInstancesDown == null)
{
avSetParams.ScheduledEventsPolicy.AllInstancesDown = new AllInstancesDown();
}
avSetParams.ScheduledEventsPolicy.AllInstancesDown.AutomaticallyApprove = this.EnableAllInstancesDown;
}

var result = this.AvailabilitySetClient.CreateOrUpdateWithHttpMessagesAsync(
this.ResourceGroupName,
this.Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ public class UpdateAzureAvailabilitySetCommand : AvailabilitySetBaseCmdlet
)]
public Hashtable Tag { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Specifies the API version to determine which scheduled events schema version will be delivered. Format: YYYY-MM-DD",
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string ScheduledEventsApiVersion { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Specifies if scheduled events should be auto-approved when all instances are down.",
ValueFromPipelineByPropertyName = true)]
public bool? EnableAllInstancesDown { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

Expand Down Expand Up @@ -84,6 +97,36 @@ public override void ExecuteCmdlet()
avSetParams.ProximityPlacementGroup.Id = null;
}

if (this.IsParameterBound(c => c.ScheduledEventsApiVersion))
{
if (avSetParams.ScheduledEventsPolicy == null)
{
avSetParams.ScheduledEventsPolicy = new ScheduledEventsPolicy();
}
if (avSetParams.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets == null)
{
avSetParams.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets = new ScheduledEventsAdditionalPublishingTargets();
}
if (avSetParams.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph == null)
{
avSetParams.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph = new EventGridAndResourceGraph();
}
avSetParams.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph.ScheduledEventsApiVersion = this.ScheduledEventsApiVersion;
}

if (this.IsParameterBound(c => c.EnableAllInstancesDown))
{
if (avSetParams.ScheduledEventsPolicy == null)
{
avSetParams.ScheduledEventsPolicy = new ScheduledEventsPolicy();
}
if (avSetParams.ScheduledEventsPolicy.AllInstancesDown == null)
{
avSetParams.ScheduledEventsPolicy.AllInstancesDown = new AllInstancesDown();
}
avSetParams.ScheduledEventsPolicy.AllInstancesDown.AutomaticallyApprove = this.EnableAllInstancesDown;
}

var result = this.AvailabilitySetClient.CreateOrUpdateWithHttpMessagesAsync(
this.AvailabilitySet.ResourceGroupName,
this.AvailabilitySet.Name,
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 @@ -24,6 +24,10 @@
* Updated Azure.Core from 1.45.0 to 1.47.3
* Added `-EnableAutomaticUpgrade` and `-TreatFailureAsDeploymentFailure` parameters (Bool) to `New-AzVmGalleryApplication` and `New-AzVmssGalleryApplication` cmdlets.
* Added `-EnableAutomaticUpgrade` and `-TreatFailureAsDeploymentFailure` parameters (Switch) to `Add-AzVmGalleryApplication` and `Add-AzVmssGalleryApplication` cmdlets.
* Added `-ScheduledEventsApiVersion` and `-EnableAllInstancesDown` parameters to support Scheduled Events policy configuration
- Added to `Update-AzVmss`, `New-AzVmss`, `Update-AzVM`, `New-AzVM`, `Update-AzAvailabilitySet`, and `New-AzAvailabilitySet` cmdlets
- `ScheduledEventsApiVersion` parameter specifies the API (Application Programming Interface) version to determine which scheduled events schema version will be delivered
- `EnableAllInstancesDown` parameter specifies if scheduled events should be auto-approved when all Virtual Machine (VM) instances are down

## Version 10.5.0
* Added `-Redeploy` switch parameter for `Update-AzHost` cmdlet to enable dedicated host redeployment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@ public string ResourceGroupName
public string Etag { get; private set; }

public ResiliencyPolicy ResiliencyPolicy { get; set; }

public ScheduledEventsPolicy ScheduledEventsPolicy { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,44 @@ private VirtualMachineScaleSet BuildVirtualMachineScaleSetParameters()
SetDefaultOrchestrationMode(parameters);
ConfigureFlexibleOrchestrationMode(parameters);
ConfigureSecuritySettings(parameters);
ConfigureScheduledEventsPolicy(parameters);

return parameters;
}

private void ConfigureScheduledEventsPolicy(VirtualMachineScaleSet parameters)
{
if (this.IsParameterBound(c => c.ScheduledEventsApiVersion))
{
if (parameters.ScheduledEventsPolicy == null)
{
parameters.ScheduledEventsPolicy = new ScheduledEventsPolicy();
}
if (parameters.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets == null)
{
parameters.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets = new ScheduledEventsAdditionalPublishingTargets();
}
if (parameters.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph == null)
{
parameters.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph = new EventGridAndResourceGraph();
}
parameters.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph.ScheduledEventsApiVersion = this.ScheduledEventsApiVersion;
}

if (this.IsParameterBound(c => c.EnableAllInstancesDown))
{
if (parameters.ScheduledEventsPolicy == null)
{
parameters.ScheduledEventsPolicy = new ScheduledEventsPolicy();
}
if (parameters.ScheduledEventsPolicy.AllInstancesDown == null)
{
parameters.ScheduledEventsPolicy.AllInstancesDown = new AllInstancesDown();
}
parameters.ScheduledEventsPolicy.AllInstancesDown.AutomaticallyApprove = this.EnableAllInstancesDown;
}
}

private void CheckImageVersionWarning(VirtualMachineScaleSet parameters)
{
if (parameters?.VirtualMachineProfile?.StorageProfile?.ImageReference?.Version?.ToLower() != ImageVersions.Latest)
Expand Down Expand Up @@ -474,6 +508,19 @@ private void WriteVMSSResult(VirtualMachineScaleSet result)
ValueFromPipeline = true)]
public PSVirtualMachineScaleSet VirtualMachineScaleSet { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Specifies the API version to determine which scheduled events schema version will be delivered. Format: YYYY-MM-DD",
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string ScheduledEventsApiVersion { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Specifies if scheduled events should be auto-approved when all instances are down.",
ValueFromPipelineByPropertyName = true)]
public bool? EnableAllInstancesDown { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,19 @@ public override void ExecuteCmdlet()
[ValidateNotNullOrEmpty]
public string[] VhdContainer { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Specifies the API version to determine which scheduled events schema version will be delivered. Format: YYYY-MM-DD",
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string ScheduledEventsApiVersion { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Specifies if scheduled events should be auto-approved when all instances are down.",
ValueFromPipelineByPropertyName = true)]
public bool? EnableAllInstancesDown { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

Expand Down Expand Up @@ -1511,6 +1524,44 @@ void InitializeAutomaticZoneRebalancingPolicy()
InitializeAutomaticZoneRebalancingPolicy();
this.VirtualMachineScaleSetUpdate.ResiliencyPolicy.AutomaticZoneRebalancingPolicy.RebalanceBehavior = this.AutomaticZoneRebalanceBehavior;
}

if (this.IsParameterBound(c => c.ScheduledEventsApiVersion))
{
if (this.VirtualMachineScaleSetUpdate == null)
{
this.VirtualMachineScaleSetUpdate = new VirtualMachineScaleSetUpdate();
}
if (this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy == null)
{
this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy = new ScheduledEventsPolicy();
}
if (this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets == null)
{
this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets = new ScheduledEventsAdditionalPublishingTargets();
}
if (this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph == null)
{
this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph = new EventGridAndResourceGraph();
}
this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph.ScheduledEventsApiVersion = this.ScheduledEventsApiVersion;
}

if (this.IsParameterBound(c => c.EnableAllInstancesDown))
{
if (this.VirtualMachineScaleSetUpdate == null)
{
this.VirtualMachineScaleSetUpdate = new VirtualMachineScaleSetUpdate();
}
if (this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy == null)
{
this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy = new ScheduledEventsPolicy();
}
if (this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy.AllInstancesDown == null)
{
this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy.AllInstancesDown = new AllInstancesDown();
}
this.VirtualMachineScaleSetUpdate.ScheduledEventsPolicy.AllInstancesDown.AutomaticallyApprove = this.EnableAllInstancesDown;
}
}

private void BuildPutObject()
Expand Down Expand Up @@ -2364,6 +2415,36 @@ void InitializeAutomaticZoneRebalancingPolicy()
InitializeAutomaticZoneRebalancingPolicy();
this.VirtualMachineScaleSetUpdate.ResiliencyPolicy.AutomaticZoneRebalancingPolicy.RebalanceBehavior = this.AutomaticZoneRebalanceBehavior;
}

if (this.IsParameterBound(c => c.ScheduledEventsApiVersion))
{
if (this.VirtualMachineScaleSet.ScheduledEventsPolicy == null)
{
this.VirtualMachineScaleSet.ScheduledEventsPolicy = new ScheduledEventsPolicy();
}
if (this.VirtualMachineScaleSet.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets == null)
{
this.VirtualMachineScaleSet.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets = new ScheduledEventsAdditionalPublishingTargets();
}
if (this.VirtualMachineScaleSet.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph == null)
{
this.VirtualMachineScaleSet.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph = new EventGridAndResourceGraph();
}
this.VirtualMachineScaleSet.ScheduledEventsPolicy.ScheduledEventsAdditionalPublishingTargets.EventGridAndResourceGraph.ScheduledEventsApiVersion = this.ScheduledEventsApiVersion;
}

if (this.IsParameterBound(c => c.EnableAllInstancesDown))
{
if (this.VirtualMachineScaleSet.ScheduledEventsPolicy == null)
{
this.VirtualMachineScaleSet.ScheduledEventsPolicy = new ScheduledEventsPolicy();
}
if (this.VirtualMachineScaleSet.ScheduledEventsPolicy.AllInstancesDown == null)
{
this.VirtualMachineScaleSet.ScheduledEventsPolicy.AllInstancesDown = new AllInstancesDown();
}
this.VirtualMachineScaleSet.ScheduledEventsPolicy.AllInstancesDown.AutomaticallyApprove = this.EnableAllInstancesDown;
}
}
}
}
3 changes: 3 additions & 0 deletions src/Compute/Compute/Models/PSAvailabilitySet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,8 @@ public string VirtualMachinesReferencesText
public string Sku { get; set; }

public SubResource ProximityPlacementGroup { get; set; }

// Gets or sets the ScheduledEventsPolicy
public ScheduledEventsPolicy ScheduledEventsPolicy { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Compute/Compute/Models/PSVirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,8 @@ public string ResourceGroupName

// Gets or sets the AddProxyAgentExtension
public bool? AddProxyAgentExtension { get; set; }

// Gets or sets the ScheduledEventsPolicy
public ScheduledEventsPolicy ScheduledEventsPolicy { get; set; }
}
}
Loading