我有一個超級簡單的腳本,它應該交換Azure站點上的插槽。來自teamcity的Azure站點插槽交換
它依靠天藍色的工具。
swap.ps1
& "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\ShortcutStartup.ps1"
Import-AzurePublishSettingsFile -PublishSettingsFile "mysubsettings.publishsettings"
Switch-AzureWebsiteSlot -Name "mysite" -Slot1 "staging" -Slot2 "production" -Force
如果我執行這個從控制檯(powershell swap.ps1
)一切完美。
如果我在TeamCity的執行此我得到:
[Step 1/1] PowerShell Executable: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
[10:05:45][Step 1/1] Working directory: C:\TeamCity\buildAgent\work\3de96e708f2408e
[10:05:45][Step 1/1] PowerShell arguments: [-NonInteractive, -ExecutionPolicy, ByPass, -File, swap.ps1]
[10:05:47][Step 1/1] For a list of all Azure cmdlets type 'get-help azure'.
[10:05:47][Step 1/1] For a list of Windows Azure Pack cmdlets type 'Get-Command *wapack*'.
[10:05:49][Step 1/1] Import-AzurePublishSettingsFile : The term 'Import-AzurePublishSettingsFile'
[10:05:49][Step 1/1] is not recognized as the name of a cmdlet, function, script file, or operable
[10:05:49][Step 1/1] program. Check the spelling of the name, or if a path was included, verify
[10:05:49][Step 1/1] that the path is correct and try again.
它喜歡它沒有正確加載蔚藍的PowerShell的,但我不明白爲什麼這可能是(特別是考慮到它已經從蔚藍的工具的輸出,行4,5)
我已經嘗試使用文件和源代碼選項具有相同的結果。
任何想法爲什麼完全相同的腳本可以在控制檯中運行,但不能在teamcity中運行?
它可能與您在TeamCity下運行的powershell版本的「bitness」有關嗎? TeamCity中有一個下拉列表,您可以選擇x86或x64。根據使用的版本,模塊可能會或可能不會被加載。只是一個猜測。 –
@DavidBrabant我試過它似乎沒有影響它 –
是否在機器上的控制檯上運行實際構建代理?快捷方式PowerShell腳本中有什麼? –