편집

다음을 통해 공유


Add-AzVmssExtension

Adds an extension to the VMSS.

Syntax

Add-AzVmssExtension
   [-VirtualMachineScaleSet] <PSVirtualMachineScaleSet>
   [[-Name] <String>]
   [[-Publisher] <String>]
   [[-Type] <String>]
   [[-TypeHandlerVersion] <String>]
   [[-AutoUpgradeMinorVersion] <Boolean>]
   [[-Setting] <Object>]
   [[-ProtectedSetting] <Object>]
   [-EnableAutomaticUpgrade <Boolean>]
   [-ForceUpdateTag <String>]
   [-ProvisionAfterExtension <String[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Add-AzVmssExtension cmdlet adds an extension to the Virtual Machine Scale Set (VMSS).

Examples

Example 1: Add an extension to the VMSS

Add-AzVmssExtension -VirtualMachineScaleSet $VMSS -Name $ExtName -Publisher $Publisher -Type $ExtType -TypeHandlerVersion $ExtVer -AutoUpgradeMinorVersion $True

This command adds an extension to the VMSS.

Example 2: Add an extension to the VMSS with settings and protected settings

$Settings = @{"fileUris" = "[]"; "commandToExecute" = ""};
$ProtectedSettings = @{"storageAccountName" = $stoname; "storageAccountKey" = $stokey};

Add-AzVmssExtension -VirtualMachineScaleSet $vmss -Name $vmssExtensionName -Publisher $vmssPublisher  `
  -Type $vmssExtensionType -TypeHandlerVersion $ExtVer -AutoUpgradeMinorVersion $True  `
  -Setting $Settings -ProtectedSetting $ProtectedSettings

Example 3: Add an extension to the VMSS with settings and protected settings

$BatchFile = "runbook.sh"
$ResourceGroupName = "HelloRG"
$VMScaleSetName = "HelloVmSS"
$TypeHandlerVersion = 2.1

#Best Practice for securd paramaters.
$protectedSettings = @{
"managedIdentity" = @{ "clientId" = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"};
}

$publicSettings = @{ 
"fileUris"= (,"https://storage.blob.core.windows.net/itfiles/$($BatchFile)");
"commandToExecute"= "sh $($BatchFile)"
}

# Get information about the scale set
$vmss = Get-AzVmss `
            -ResourceGroupName $ResourceGroupName `
            -VMScaleSetName $VMScaleSetName

Add-AzVmssExtension -VirtualMachineScaleSet $vmss `
    -Name "CustomScript" `
    -Publisher "Microsoft.Azure.Extensions" `
    -Type "CustomScript" `
    -TypeHandlerVersion $TypeHandlerVersion `
    -AutoUpgradeMinorVersion $true `
    -Setting $publicSettings `
    -ProtectedSetting $protectedSettings

Update-AzVmss `
    -ResourceGroupName $ResourceGroupName `
    -Name $VMScaleSetName `
    -VirtualMachineScaleSet $vmss

This command adds an extension to the VMSS with a sample bash script on a blob storage, specify the url of blob storage and executable command in settings and security access in protected settings.

Parameters

-AutoUpgradeMinorVersion

Indicates whether the extension version should be automatically updated to a newer minor version.

Type:Nullable<T>[Boolean]
Position:5
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-EnableAutomaticUpgrade

Indicates whether the extension should be automatically upgraded by the platform if there is a newer version of the extension available.

Type:Nullable<T>[Boolean]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ForceUpdateTag

If a value is provided and is different from the previous value, the extension handler will be forced to update even if the extension configuration has not changed.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Name

Specifies the name of the extension that this cmdlet adds.

Type:String
Position:1
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ProtectedSetting

Specifies private configuration for the extension, as a string. This cmdlet encrypts the private configuration.

Type:Object
Position:7
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ProvisionAfterExtension

Collection of extension names after which this extension needs to be provisioned.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Publisher

Specifies the name of the extension publisher. The publisher provides a name when the publisher registers an extension. This can use the Get-AzVMImagePublisher cmdlet to get the publisher.

Type:String
Position:2
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Setting

Specifies the public configuration, as a string, for the extension. This cmdlet does not encrypt public configuration.

Type:Object
Position:6
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Type

Specifies the extension type. You can use the Get-AzVMExtensionImageType cmdlet to get the extension type.

Type:String
Position:3
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-TypeHandlerVersion

Specifies the version of the extension to use for this virtual machine. You can use the Get-AzVMExtensionImage cmdlet to get the version of the extension.

Type:String
Position:4
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-VirtualMachineScaleSet

Specify the VMSS object. You can use the New-AzVmssConfig to create the object.

Type:PSVirtualMachineScaleSet
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

PSVirtualMachineScaleSet

String

Nullable<T>[[System.Boolean, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]

Object

Outputs

PSVirtualMachineScaleSet