Visual Studio Teams Services(オンライン)によるリリース管理を使用しています。私たちはホステッドビルドエージェントを使用しており、カスタムエージェントを管理するオーバーヘッドを本当に避けたいと思っています。
私が必要とするアイテムの1つは、AzureRMPowerShellモジュールです。エージェントでは5.1.1までのバージョンが利用可能ですが、 6.0.0が必要です。
私がやりたいのは、リリースプロセス(PowerShell)のステップを使用してバージョン6.0.0を取得し、代わりにthartを使用することですが、それを完全に機能させることはできません。私はすべてが行き詰まっているいくつかのアプローチを試しましたが、現在のものは次のとおりです。
Write-Output "------------------ Install package provider ------------------"
Find-PackageProvider -Name "NuGet" | Install-PackageProvider -Scope CurrentUser -Force
Write-Output "------------------ Remove Modules ------------------"
Get-Module -ListAvailable | Where-Object {$_.Name -like 'AzureRM*'} | Remove-Module
Write-Output "------------------ Install the AzureRM version we want - 6.0.1! ------------------"
Install-Package AzureRM -RequiredVersion 6.0.1 -Scope CurrentUser -Force
Write-Output "------------------ Import AzureRM 6.0.1 ------------------"
Import-Module AzureRM -RequiredVersion 6.0.1
これはすべて正常に機能します(つまり、クラッシュしません...)が、6.0.1コマンドレットの1つを使用しようとすると、エラーが発生します。
Get-AzureRmADGroup:AzurePowerShellセッションが正しく初期化されていません。モジュールをインポートして、再試行してください。
AzureRM 6.0.1をデプロイし、ホストされたエージェントで使用するために使用できる、どこが間違っているのか、または代替戦略についてのアイデアはありますか?
私はついにそれを理解しました-同じように苦しんでいる他の人のために答えを追加します。
重要なのは、AzureRMモジュールのアップグレード後にログインすることです。
PowerShellコード:
Write-Output "------------------ Start: Upgrade AzureRM on build host ------------------"
Write-Output "- - - - - Install package provider"
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
Write-Output "- - - - - List Modules Before"
Get-Module -ListAvailable| where {$_.Name -Like “*AzureRM*”} | Select Name, Version
Write-Output "- - - - - Remove alll existing AzureRM Modules"
Get-Module -ListAvailable | Where-Object {$_.Name -like '*AzureRM*'} | Remove-Module -Force
Write-Output "- - - - - Install AzureRM 6.0.1"
Install-Module -Name AzureRM -RequiredVersion 6.0.1 -Force -Scope CurrentUser
Write-Output "- - - - - Import AzureRM 6.0.1"
Import-Module AzureRM -Force -Verbose -Scope Local
Write-Output "- - - - - List Modules After"
Get-Module -ListAvailable| where {$_.Name -Like “*AzureRM*”} | Select Name, Version
Write-Output "------------------ End: Upgrade AzureRM on build host ------------------"
Write-Output "------------------ Start: LoginToAzure ------------------"
$SecurePassword = ConvertTo-SecureString $AdminPassword -AsPlainText -Force
$AdminCredential = New-Object System.Management.Automation.PSCredential ($AdminUserEmailAddress, $SecurePassword)
Login-AzureRmAccount -Credential $AdminCredential
Get-AzureRmSubscription –SubscriptionId $SubscriptionId | Select-AzureRmSubscription
Write-Output "------------------ End: LoginToAzure ------------------"
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加