现在,我可以在本地运行时从我的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/ –