AzureVmssDeployment@1 - Azure VM scale set deployment v1 task
Deploy a virtual machine scale set image.
Note
This version of the task uses Azure RBAC to connect to Azure storage. For more information, see Configure Azure RBAC to access Azure storage.
Syntax
# Azure VM scale set deployment v1
# Deploy a virtual machine scale set image.
- task: AzureVmssDeployment@1
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.
Select 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
.
Choose between updating a VM scale set by using a VHD image and/or by running deployment/install scripts using Custom Script VM extension.
The VHD image approach is better for scaling quickly and doing rollback. The extension approach is useful for post deployment configuration, software installation, or any other configuration / management task.
You can use a VHD image to update a VM scale set only when it was created by using a custom 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 can be used for VM scale set created by using either custom image or platform/gallery image.
vmssName
- Virtual Machine scale set name
string
. Required.
Name of VM scale set which you want to update by using either a VHD image or by using Custom script VM extension.
vmssOsType
- OS type
string
. Required. Allowed values: Windows
, Linux
.
Select the operating system type of VM scale set.
imageUrl
- Image URL
string
. Required when action = Update image || action = UpdateImage
.
Specify the URL of VHD image. If it is an Azure storage blob URL, the storage account location should be same as scale set location.
customScriptsDirectory
- Custom script directory
string
. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage
.
Path to directory containing custom script(s) that will be run by using 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 string.
customScript
- Command
string
. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage
.
The script that will be run by using Custom Script VM extension. This script can invoke other scripts in the directory. The script will be invoked with arguments passed below.
This script in conjugation with such arguments can be used to execute commands. For example:
1. Update-DatabaseConnectionStrings.ps1 -clusterType dev -user $(dbUser) -password $(dbUserPwd) will update connection string in web.config of web application.
2. install-secrets.sh --key-vault-type prod -key serviceprincipalkey will create an encrypted file containing service principal key.
customScriptArguments
- Arguments
string
. Optional. Use when action = Configure application startup || action = Update image || action = UpdateImage
.
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
.
The Custom Script Extension downloads and executes scripts provided by you on each virtual machines in the VM scale set. These scripts will be stored in the storage account specified here. Specify a pre-existing ARM storage account.
skipArchivingCustomScripts
- Skip Archiving custom scripts
boolean
. Default value: false
.
By default, this task creates a compressed archive of directory containing 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'
Configure Azure RBAC to access Azure storage
This version of the task uses an Azure Resource Manager service connection configured using workload identity federation and Azure RBAC to connect to Azure storage instead of storage account keys or shared access signatures (SAS). To connect to Azure storage from this task, you must assign the Storage Blob Data Contributor role on the storage account to the identity of the service connection configured for azureSubscription
.
For more information, see Assign an Azure role for access to blob data and Steps to assign a role.
The AzureVmssDeployment@1
task requires the following additional RBAC roles configured to access the storage account configured in customScriptsStorageAccount
.
Role | Resource | User |
---|---|---|
Contributor or Virtual Machine Contributor | Virtual Machine Scale Set | The identity of the service connection configured for azureSubscription |
Storage Blob Data Contributor | Azure storage account that holds the custom script | The identity of the service connection configured for azureSubscription |
Storage Blob Data Reader | Azure storage account that holds the custom script | The Virtual Machine Scale Set System-assigned Managed Identity |
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 |