संपादित करें

इसके माध्यम से साझा किया गया


AzureVmssDeployment@0 - Azure VM scale set deployment v0 task

This task deploys a Virtual Machine scale set image.

Syntax

# Azure VM scale set deployment v0
# Deploy a virtual machine scale set image.
- task: AzureVmssDeployment@0
  inputs:
  # Azure Details
    azureSubscription: # string. Alias: ConnectedServiceName. Required. Azure subscription. 
    action: 'Update image' # 'Update image' | 'Configure application startup'. Required. Action. Default: Update image.
    vmssName: # string. Required. Virtual Machine scale set name. 
    vmssOsType: # 'Windows' | 'Linux'. Required. OS type. 
  # Image Details
    #imageUrl: # string. Required when action = Update image || action = UpdateImage. Image URL. 
  # Configure start-up
    #customScriptsDirectory: # string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage. Custom script directory. 
    #customScript: # string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage. Command. 
    #customScriptArguments: # string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage. Arguments. 
    #customScriptsStorageAccount: # string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage. Azure storage account where custom scripts will be uploaded. 
  # Advanced
    #skipArchivingCustomScripts: false # boolean. Skip Archiving custom scripts. Default: false.
# Azure VM scale set Deployment v0
# Deploy Virtual Machine scale set image.
- task: AzureVmssDeployment@0
  inputs:
  # Azure Details
    azureSubscription: # string. Alias: ConnectedServiceName. Required. Azure subscription. 
    action: 'Update image' # 'Update image' | 'Configure application startup'. Required. Action. Default: Update image.
    vmssName: # string. Required. Virtual Machine scale set name. 
    vmssOsType: # 'Windows' | 'Linux'. Required. OS type. 
  # Image Details
    #imageUrl: # string. Required when action = Update image || action = UpdateImage. Image URL. 
  # Configure start-up
    #customScriptsDirectory: # string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage. Custom script directory. 
    #customScript: # string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage. Command. 
    #customScriptArguments: # string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage. Arguments. 
    #customScriptsStorageAccount: # string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage. Azure storage account where custom scripts will be uploaded. 
  # Advanced
    #skipArchivingCustomScripts: false # boolean. Skip Archiving custom scripts. Default: false.

Inputs

azureSubscription - Azure subscription
Input alias: ConnectedServiceName. string. Required.

Specifies the Azure Resource Manager subscription for the scale set.


action - Action
string. Required. Allowed values: Update image (Update VM Scale set by using an image), Configure application startup (Run Custom Script VM extension on VM scale set). Default value: Update image.

Updates a VM scale set by the chosen method, using a VHD image and/or by running deployment/install scripts using the Custom Script VM Extension.

The VHD image approach is better for scaling quickly and doing rollback. When a VM scale set is created by using a custom image, it can be updated by a VHD image. The update will fail if the VM scale set was created by using a platform/gallery image available in Azure.

The Custom Script VM Extension approach is useful for post deployment configuration, software installation, or any other configuration/management task. The Custom Script VM Extension approach can be used for a VM scale set created by using either a custom image or a platform/gallery image.


vmssName - Virtual Machine scale set name
string. Required.

Specifies the name of the VM scale setting to update. Use either a VHD image or a Custom Script VM Extension.


vmssOsType - OS type
string. Required. Allowed values: Windows, Linux.

Specifies the operating system type of the VM scale set.


imageUrl - Image URL
string. Required when action = Update image || action = UpdateImage.

Specifies the URL of the VHD image. If it's an Azure storage blob URL, the storage account location is the same as the scale set location.


customScriptsDirectory - Custom script directory
string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage.

Optional. The path to the directory containing the custom script(s) that are run by using the Custom Script VM Extension. The extension approach is useful for post deployment configuration, application/software installation, or any other application configuration/management task. For example, the script can set a machine level environment variable which the application uses, like database connection strings.


customScript - Command
string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage.

Optional. The script that is run by using the Custom Script VM Extension. This script can invoke other scripts in the directory and is invoked with the arguments passed below.
In conjunction with such arguments, this script can be used to execute commands.

For example:

  1. Update-DatabaseConnectionStrings.ps1 -clusterType dev -user $(dbUser) -password $(dbUserPwd) updates the connection string in web.config of the web application.
  2. install-secrets.sh --key-vault-type prod -key serviceprincipalkey creates an encrypted file containing a service principal key.

customScriptArguments - Arguments
string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage.

Optional. The custom script will be invoked with arguments passed. Build/release variables can be used, which makes it easy to use secrets.


customScriptsStorageAccount - Azure storage account where custom scripts will be uploaded
string. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage.

Optional. The Custom Script Extension downloads and executes the provided scripts on each virtual machine in the VM scale set. These scripts will be stored in the pre-existing ARM storage account specified here.


skipArchivingCustomScripts - Skip Archiving custom scripts
boolean. Default value: false.

Optional. By default, this task creates a compressed archive of the directory containing the custom scripts. This improves performance and reliability while uploading to Azure storage. If not selected, archiving will not be done and all files will be individually uploaded.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

None.

Remarks

Use this task to deploy a Virtual Machine scale set image.

The script execution is reported as successful, however the VMSS instances are not updated

Scale sets have an upgrade policy that determine how VMs are brought up-to-date with the latest scale set model, and if the upgrade policy is set to manual you must manually upgrade each VM. For more information, see How to bring VMs up-to-date with the latest scale set model. You can change the update policy or manually upgrade each VM. For example, to upgrade the policy to Automatic, use the following Az CLI command: az vmss update --set upgradePolicy.mode=Automatic -g <resource group name> -n <vmss name>

Error: 'Permission denied: Script is not executable'

This issue occurs if you try to run a custom script, but the script isn't executable.

To resolve the issue, first make sure that the customScript input doesn't have ./ or anything else before the script name 'test.sh':

    customScript: 'test.sh'

Next, try adding a command line task before the virtual machine scale set task:

    - task: CmdLine@2
      inputs:
        script: 'chmod 777 $(System.DefaultWorkingDirectory)/test.sh' 

Requirements

Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.209.0 or greater
Task category Deploy
Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.0.0 or greater
Task category Deploy