asp.net - Is possible to execute Powershell Azure CMDlets from web application? -
now can execute powershell azure cmdlets , scripts asp mvc web app when running locally, when deployment azure web sites powershell azure cmdlets doesn't work.
error message:
the term 'get-azuresubscription' not recognized name of cmdlet, function, script file, or operable program. check spelling of name, or if path included, verify path correct , try again.
i guess not work because "azure cmdlets" not installed on web server
what can do? advice?
hi again, im testing application hosted in iis8 in azure virtual machine, again when app deployed server cannot use azure cmdlets, azure cmdlets installed on virtual machine.
when debug app in vm visual studio can use cmdlets, when app deployed cmdlets no recognized.
there else need setup in order use azure cmdlets???
this example of 1 function, function populate dropdownlist result, in localhost works fine, in 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; }
then simple script
(get-azurevmimage).imagefamily | sort -unique
i tried
import-module -name "${env:programfiles(x86)}\microsoft sdks\azure\powershell\servicemanagement\azure" (get-azurevmimage).imagefamily | sort -unique
and tried (i cut code...)
public ienumerable<selectlistitem> getimagefamily() { ... shell.commands.addscript("(get-azurevmimage).imagefamily | sort -unique"); collection<psobject> results = shell.invoke(); ... }
to answer specific question, no not possible in azure web apps (formerly azure websites).
you have options though.
the powershell cmdlets, part, wrap service management api , resource manager api. these rest api's depending on trying do, use these instead , call api directly application using http/s calls. i recommend taking approach.
if must take dependency on azure powershell application, use azure cloud service web role instead , install azure powershell cmdlets using startup task.
you take iaas approach , host own iis server (or server farm) in azure virtual machines full control of configuration of machine. of course, take on full responsibility maintaining vm(s) if take approach.
personally, avoid options 2 , 3. it's not design. degree regret mentioning them because run other issues trying them work. but, wanted thorough in answer.
Comments
Post a Comment