現在,我可以在本地運行時從我的ASP MVC Web應用程序執行Powershell Azure cmdlet和腳本,但是當我部署到Azure網站時,Powershell Azure cmdlet不起作用。是否可以從Web應用程序執行Powershell Azure CMDlet?
錯誤消息:
The term 'Get-AzureSubscription' 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.
我想這是行不通的,因爲「天藍色的cmdlet」沒有Web服務器
我能做些什麼上?有什麼建議?
嗨再次,即時通訊目前正在測試在Azure中的虛擬機一個IIS8託管的應用程序,但同樣,當應用程序部署到我不能使用Azure中的cmdlet的服務器上,在Azure的cmdlet已經安裝在虛擬機。
當我用Visual Studio在VM中調試應用程序時,我可以使用cmdlet,但是當部署應用程序時,cmdlet不會被識別。
還有一些我需要設置才能使用Azure cmdlet?
這是一個功能的一個例子,該函數填充下拉列表,其結果,在本地主機能正常工作,在IIS。
public IEnumerable<SelectListItem> getImageFamily()
{
var shell = PowerShell.Create();
shell.Commands.AddScript("C:\\inetpub\\wwwroot\\appName\Scripts\\test.ps1");
Collection<PSObject> results = shell.Invoke();
List<SelectListItem> items = new List<SelectListItem>();
foreach (var psObject in results)
{
string image = psObject.BaseObject.ToString();
items.Add(new SelectListItem { Text = image, Value = image });
}
return items;
}
那麼這是一個簡單的腳本
(Get-AzureVMImage).ImageFamily | sort -Unique
我也試過
Import-Module -Name "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure"
(Get-AzureVMImage).ImageFamily | sort -Unique
而且還試圖(我切一些代碼...)
public IEnumerable<SelectListItem> getImageFamily()
{
...
shell.Commands.AddScript("(Get-AzureVMImage).ImageFamily | sort -Unique");
Collection<PSObject> results = shell.Invoke();
...
}
你想做什麼?我對Azure網站了解不多,但您需要安裝Azure PowerShell才能使用這些cmdlet:http://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/ –