AzureVmssDeployment@0 - Azure VM 规模集部署 v0 任务
此任务部署虚拟机规模集映像。
语法
# 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.
输入
azureSubscription
-
Azure 订阅
输入别名:ConnectedServiceName
。
string
。 必填。
指定规模集的 Azure 资源管理器订阅。
action
-
操作
string
。 必填。 允许的值:Update image
(使用映像更新 VM 规模集),Configure application startup
(在 VM 规模集上运行自定义脚本 VM 扩展)。 默认值:Update image
。
使用 VHD 映像和/或使用自定义脚本 VM 扩展运行部署/安装脚本,通过所选方法更新 VM 规模集。
VHD 映像方法 更适合快速缩放和进行回滚。 使用自定义映像创建 VM 规模集时,VHD 映像可以更新它。 如果 VM 规模集是使用 Azure 中可用的平台/库映像创建的,则更新将失败。
自定义脚本 VM 扩展方法 可用于部署后配置、软件安装或任何其他配置/管理任务。 自定义脚本 VM 扩展方法可用于使用自定义映像或平台/库映像创建的 VM 规模集。
vmssName
-
虚拟机规模集名称
string
。 必填。
指定要更新的 VM 规模设置的名称。 使用 VHD 映像或自定义脚本 VM 扩展。
vmssOsType
-
OS 类型
string
。 必填。 允许的值:Windows
、Linux
。
指定 VM 规模集的操作系统类型。
imageUrl
-
图像 URL
string
。
action = Update image || action = UpdateImage
时是必需的。
指定 VHD 映像的 URL。 如果是 Azure 存储 Blob URL,则存储帐户位置与规模集位置相同。
customScriptsDirectory
-
自定义脚本目录
string
。 自选。 当 action = Configure application startup || action = Update image || action = UpdateImage
时使用。
自选。 包含使用自定义脚本 VM 扩展运行的自定义脚本的目录的路径。 扩展方法适用于部署后配置、应用程序/软件安装或任何其他应用程序配置/管理任务。 例如,该脚本可以设置应用程序使用的计算机级环境变量,例如数据库连接字符串。
customScript
-
命令
string
。 自选。 当 action = Configure application startup || action = Update image || action = UpdateImage
时使用。
自选。 使用自定义脚本 VM 扩展运行的脚本。 此脚本可以调用目录中的其他脚本,并使用下面传递的参数调用。
结合此类参数,此脚本可用于执行命令。
例如:
-
Update-DatabaseConnectionStrings.ps1 -clusterType dev -user $(dbUser) -password $(dbUserPwd)
更新 Web 应用程序web.config
中的连接字符串。 -
install-secrets.sh --key-vault-type prod -key serviceprincipalkey
创建包含服务主体密钥的加密文件。
customScriptArguments
-
参数
string
。 自选。 当 action = Configure application startup || action = Update image || action = UpdateImage
时使用。
自选。 将使用传递的参数调用自定义脚本。 可以使用生成/发布变量,从而轻松使用机密。
customScriptsStorageAccount
-
将上传自定义脚本的 Azure 存储帐户
string
。 自选。 当 action = Configure application startup || action = Update image || action = UpdateImage
时使用。
自选。 自定义脚本扩展会在 VM 规模集中的每个虚拟机上下载并执行提供的脚本。 这些脚本将存储在此处指定的预先存在的 ARM 存储帐户中。
skipArchivingCustomScripts
-
跳过存档自定义脚本
boolean
。 默认值:false
。
自选。 默认情况下,此任务会创建包含自定义脚本的目录的压缩存档。 这可以提高上传到 Azure 存储时的性能和可靠性。 如果未选中,则不会完成存档,并且将单独上传所有文件。
任务控制选项
除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性。
输出变量
没有。
言论
使用此任务部署虚拟机规模集映像。
脚本执行报告为成功,但 VMSS 实例未更新
规模集具有一个升级策略,用于确定 VM 如何使用最新的规模集模型 up-to日期,如果升级策略设置为手动,则必须手动升级每个 VM。 有关详细信息,请参阅 如何使用最新的规模集模型将 VM up-to日期。 可以更改更新策略或手动升级每个 VM。 例如,若要将策略升级到 Automatic
,请使用以下 Az CLI 命令:az vmss update --set upgradePolicy.mode=Automatic -g <resource group name> -n <vmss name>
错误:“权限被拒绝:脚本不可执行”
如果尝试运行自定义脚本,但脚本不可执行,则会出现此问题。
若要解决此问题,请先确保 customScript
输入在脚本名称 'test.sh'
之前没有 ./
或其他任何内容:
customScript: 'test.sh'
接下来,请尝试在虚拟机规模集任务之前添加命令行任务:
- task: CmdLine@2
inputs:
script: 'chmod 777 $(System.DefaultWorkingDirectory)/test.sh'