Edit

New-AzVmssLifecycleHookConfig

Creates an in-memory lifecycle hook configuration object for use with a Virtual Machine Scale Set (VMSS).

Syntax

Default (Default)

New-AzVmssLifecycleHookConfig
    -Type <String>
    [-WaitDuration <String>]
    [-DefaultAction <String>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The New-AzVmssLifecycleHookConfig cmdlet creates a lifecycle hook configuration object that can be passed to Set-AzVmssLifecycleHooksProfile or New-AzVmssConfig.

Lifecycle hooks let customers register hooks that fire before VMSS Auto OS Upgrade phases, then respond to events on a per-VM basis (approve, reject, or delay) before the platform proceeds.

Examples

Example 1: Create a lifecycle hook for Auto OS upgrade scheduling

$hook = New-AzVmssLifecycleHookConfig -Type 'UpgradeAutoOSScheduling' -WaitDuration 'PT8H'

This example creates a lifecycle hook that fires before Auto OS Upgrade scheduling, with an 8-hour wait duration. Because -DefaultAction is not specified, the service applies its own default when the wait duration expires.

Example 2: Create a lifecycle hook with explicit default action

$hook = New-AzVmssLifecycleHookConfig -Type 'UpgradeAutoOSRollingBatchStarting' -WaitDuration 'PT30M' -DefaultAction 'Approve'

This example creates a lifecycle hook that fires before each rolling batch starts, with a 30-minute wait duration and an explicit default action of Approve.

Example 3: Use the hook in a new VMSS

$hook   = New-AzVmssLifecycleHookConfig -Type 'UpgradeAutoOSScheduling' -WaitDuration 'PT8H'
$config = New-AzVmssConfig -Location 'eastus' -SkuCapacity 2
$config = Set-AzVmssLifecycleHooksProfile -VirtualMachineScaleSet $config -LifecycleHook $hook
New-AzVmss -ResourceGroupName 'myRg' -VMScaleSetName 'myVmss' -VirtualMachineScaleSet $config

This example creates a VMSS with a lifecycle hook attached.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultAction

Specifies the action applied to a target resource in the lifecycle hook event if the platform does not receive a response from the customer before the wait duration expires. Accepted values: 'Approve', 'Reject'. If omitted, the service applies its own default.

Parameter properties

Type:String
Default value:None
Accepted values:Approve, Reject
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:2
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Type

Specifies the type of the lifecycle hook. Possible values: 'UpgradeAutoOSScheduling', 'UpgradeAutoOSRollingBatchStarting'.

Parameter properties

Type:String
Default value:None
Accepted values:UpgradeAutoOSScheduling, UpgradeAutoOSRollingBatchStarting
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-WaitDuration

Specifies the time duration the lifecycle hook event waits for a customer response before applying the default action. Must be in ISO 8601 duration format, for example 'PT8H' (8 hours) or 'PT30M' (30 minutes).

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:1
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

Outputs

LifecycleHook