如何在VSTS任务中使用最新的AzureRM [英] How to use latest AzureRM in a VSTS task

查看:76
本文介绍了如何在VSTS任务中使用最新的AzureRM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行命令以删除远程Azure资源组上的主题或队列.命令之一是"Get-AzureRmServiceBusQueue".

I want to execute a command to remove a topic or queue on a remote azure resource group. One of the commands is 'Get-AzureRmServiceBusQueue'.

我在VSTS的托管代理中使用Azure Powershell任务(使用Azure资源管理器).此任务使用的是Azure Powershell 2.0.1.

I use the Azure Powershell task (using the Azure Resource Manager) within a hosted agent of VSTS. This task is using the Azure Powershell 2.0.1.

执行释放时,代理将返回此故障:

When I perform the release the agent is returning this failure:

"[error]The term 'Get-AzureRmServiceBusQueue' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."

我检查了ServiceBus cmdlet仅在Azure Powershell的较新版本中提供(例如:最新的4.3.1).

I checked that the ServiceBus cmdlet is only provided in newer versions of the Azure Powershell (for example: the latest 4.3.1).

我可以执行安装模块-Name AzureRM"吗?

Can I perform a 'Install-Module -Name AzureRM' ?

推荐答案

根据您的描述,我在实验室中进行了测试.当前,如果您使用最新版本的Azure PowerShell,则VSTS任务将使用4.2.1版本. cmdlet Get-AzureRmServiceBusQueue可完成我的任务.

According to your description, I test in my lab. Currently, if you use the latest version Azure PowerShell, VSTS task uses 4.2.1 version. cmdlet Get-AzureRmServiceBusQueue works on my task.

代理队列,我使用Hosted VS2017.这是我得到的日志.

Agent queue I use Hosted VS2017. Here is the log I get.

2017-08-25T02:34:00.0731521Z ##[section]Starting: Azure PowerShell script: InlineScript
2017-08-25T02:34:00.0911526Z ==============================================================================
2017-08-25T02:34:00.0921520Z Task         : Azure PowerShell
2017-08-25T02:34:00.0921520Z Description  : Run a PowerShell script within an Azure environment
2017-08-25T02:34:00.0921520Z Version      : 2.0.1
2017-08-25T02:34:00.0921520Z Author       : Microsoft Corporation
2017-08-25T02:34:00.0921520Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613749)
2017-08-25T02:34:00.0921520Z ==============================================================================
2017-08-25T02:34:02.8332045Z ##[command]Import-Module -Name C:\Modules\azurerm_4.2.1\AzureRM\4.2.1\AzureRM.psd1 -Global
2017-08-25T02:34:11.8296290Z ##[command]Import-Module -Name C:\Modules\azure_4.2.1\AzureRM.Profile\3.2.1\AzureRM.Profile.psm1 -Global
2017-08-25T02:34:15.2798961Z ##[command]Add-AzureRMAccount -ServicePrincipal -Tenant ******** -Credential System.Management.Automation.PSCredential -Environment AzureCloud
2017-08-25T02:34:16.1729615Z ##[command]Select-AzureRMSubscription -SubscriptionId 3b4d41fa-****-****-bc11-13d221b3b77d -TenantId ********
2017-08-25T02:34:16.3229723Z ##[command]& 'd:\a\_temp\a063a14b-863f-4439-bd37-29f7ee515754.ps1' 
2017-08-25T02:34:16.9640151Z 
2017-08-25T02:34:16.9640151Z 
2017-08-25T02:34:16.9640151Z     Directory: C:\Modules\azure_4.2.1
2017-08-25T02:34:16.9640151Z 
2017-08-25T02:34:16.9640151Z 
2017-08-25T02:34:16.9640151Z ModuleType Version    Name                                ExportedCommands                                             
2017-08-25T02:34:16.9640151Z ---------- -------    ----                                ----------------                                             
2017-08-25T02:34:16.9640151Z Script     4.2.1      Azure                               {Get-AzureAutomationCertificate, Get-AzureAutomationConnec...
2017-08-25T02:34:16.9650152Z 
2017-08-25T02:34:16.9650152Z 
2017-08-25T02:34:16.9650152Z     Directory: C:\Program Files\WindowsPowerShell\Modules

此外,您可以参考此链接:托管代理.

托管:AzureRM PowerShell 3.6.0

Hosted: AzureRM PowerShell 3.6.0

托管VS2017:AzureRM PowerShell 4.1.0(根据我的测试,当前版本为4.2.1).

Hosted VS2017:AzureRM PowerShell 4.1.0(According to my test, currently, the version is 4.2.1).

这篇关于如何在VSTS任务中使用最新的AzureRM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆