2016-07-14 41 views
0

我有一個超級簡單的腳本,它應該交換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中運行?

+0

它可能與您在TeamCity下運行的powershell版本的「bitness」有關嗎? TeamCity中有一個下拉列表,您可以選擇x86或x64。根據使用的版本,模塊可能會或可能不會被加載。只是一個猜測。 –

+0

@DavidBrabant我試過它似乎沒有影響它 –

+0

是否在機器上的控制檯上運行實際構建代理?快捷方式PowerShell腳本中有什麼? –

回答

0

所以我發現了這個問題,林不知道爲什麼它被隔離的TeamCity,但問題是與此有關:

有一個已知的問題,使用PowerShell $ ENV:PSModulePath可以 發生從WebPI安裝時。如果您的計算機由於系統更新或其他安裝而需要重新啓動 ,則可能會導致更新 $ env:PSModulePath未包含Azure PowerShell安裝的路徑,其中包含Azure PowerShell的路徑爲 。如果發生這種情況,在安裝或升級 之後嘗試使用Azure PowerShell cmdlet時,可能會看到'cmdlet未識別' 消息。如果發生這種情況,重新啓動機器應該 解決問題。

https://azure.microsoft.com/en-us/documentation/articles/web-sites-staged-publishing/

當我重新啓動機器TeamCity的一切運行正常。

相關問題