最初设置Release的时候使用Microsoft-hosted Agent, 有时候会出现Release中状态提示失败但是包正常部署成功的现象。决定换成配置更灵活性能更好的Build machine作为Self-Hosted Agent.
最主要是确认Agent Pool中Default Agent的Capabilities是否安装了AzurePS 。
如果没有安装需要在Build Machine的Powershell中执行如下命令:
Install-Module -Name Azure
Install-Module -Name AzureRM -AllowClobber
然后在命令提示行cmd中设置如下环境变量:
set BUILDDRIVE=C:\Program Files\WindowsPowerShell\Modules;C:\windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\PowerShell\Modules\;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.1455.1
重启Build machine就可以使用self-hosted agent了