Col*_*kay 7 azure-powershell azure-devops
我想在Azure DevOps发布管道中使用Azure PowerShell模块(又名Az模块)。但是,现有的PowerShell选项似乎无效。我已经尝试了各种方法,但是安装新的Az模块只会带来很多错误,包括Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook.
常规的PowerShell任务没有内置的任何Azure模块。AzurePowerShell任务使用已淘汰的Azure RM PowerShell模块(即,它仍受支持,但不会添加任何新功能)。
上面的错误很可能是由于Azure PowerShell任务启动时在运行我的脚本之前执行以下操作引起的:
2019-01-13T13:34:14.5416432Z ==============================================================================
2019-01-13T13:34:14.5416555Z Task : Azure PowerShell
2019-01-13T13:34:14.5416623Z Description : Run a PowerShell script within an Azure environment
2019-01-13T13:34:14.5416705Z Version : 3.1.18
2019-01-13T13:34:14.5416762Z Author : Microsoft Corporation
2019-01-13T13:34:14.5416831Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613749)
2019-01-13T13:34:14.5416969Z ==============================================================================
2019-01-13T13:34:20.3546127Z ##[command]Import-Module -Name C:\Modules\AzureRm_6.7.0\AzureRM\6.7.0\AzureRM.psd1 -Global
2019-01-13T13:34:58.4365259Z ##[command]Clear-AzureRmContext -Scope Process
2019-01-13T13:34:59.2732327Z ##[command]Disable-AzureRmContextAutosave -ErrorAction SilentlyContinue
2019-01-13T13:35:00.1691359Z ##[command]Add-AzureRMAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -Environment AzureCloud @processScope
2019-01-13T13:35:01.5702545Z ##[command] Select-AzureRMSubscription -SubscriptionId d5eaaba3-2968-456a-98a4-e53e961fc896 -TenantId ***
2019-01-13T13:35:02.1592660Z ##[command]& 'D:\a\r1\a\ws-build\tools\install-dependencies.ps1'
Run Code Online (Sandbox Code Playgroud)
自然,在一个新项目中,我不想使用不再高级的模块来创建PowerShell脚本。
再想一想,即使我确实设法克服了这一点,我也必须以某种方式对Azure进行身份验证,现有的Azure DevOps UI会为我进行身份验证,而我还看不到如何使用Az模块来做到这一点。
谷歌搜索似乎无济于事,因为大多数信息仍与已弃用的AzureRM模块相关。所以...总而言之。
如何在Azure DevOps发布管道中使用Azure(Az)Powershell模块?
尝试使用 Azure Powershell 任务版本 4.*(预览版)。此功能仍处于预览阶段。将此与自托管代理一起使用。这将很快针对 Microsoft 托管代理发布。
归档时间: |
|
查看次数: |
4356 次 |
最近记录: |