Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RE: How do I run Azure powershell commands? #47

Closed
stuartjdavies opened this issue Nov 11, 2014 · 7 comments
Closed

RE: How do I run Azure powershell commands? #47

stuartjdavies opened this issue Nov 11, 2014 · 7 comments

Comments

@stuartjdavies
Copy link

Hi,

How do I run Azure powershell commands?

Below is my script:

#r "../packages/FSharp.Management.0.1.1/lib/net40/FSharp.Management.dll"
#r "../packages/FSharp.Management.0.1.1/lib/net40/FSharp.Management.PowerShell.dll"
#r "System.Management.Automation"
#r "Microsoft.Management.Infrastructure"

open FSharp.Management
open Microsoft.PowerShell

type PS = PowerShellProvider< PSSnapIns="WDeploySnapin3.0", Is64BitRequired=false>
PowerShellProvider.Runtime

PS.``Set-ExecutionPolicy``(executionPolicy=ExecutionPolicy.RemoteSigned) 
PS.``Import-Module``(name=[|"Azure"|])

Some initialization...

// Ideal execution which doesn't seem to work
PS.``Add-AzureAccount``(  some params ... )

See "http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/"
for more examples

How do I run commands from the Azure module?

In my opinion this would be an awesome feature for F# I think because it would open up many possibilities.

Regards
Stuart Davies

@dsyme
Copy link
Contributor

dsyme commented Jun 5, 2015

Ping @forki @vasily-kirichenko @sergey-tihon @dtchepak We should answer this :)

@stuartjdavies - did you find a solution for this?

@dsyme dsyme added the question label Jun 5, 2015
@vasily-kirichenko
Copy link
Contributor

Sorry, I try To stay away from both PS and Azure.

@sergey-tihon
Copy link
Member

@stuartjdavies sorry, i missed this question.

As I understand, it is not possible right now.
In order to get intellisense over Azure commands TP should load it before type inference.
So, it sounds like we should add new parameter to PowershellProvider.

@stuartjdavies
Copy link
Author

@dsyme @forki @vasily-kirichenko @sergey-tihon

No, I didn't find a solution. It was a while since I looked at this but by memory I don't think it works for any package you want to load. Not just the azure package. If this is the case it might be a good feature to add. Anyway, there may better things to spend time on.

@ChristopherBuller
Copy link

I worked thru creating this exact feature before, The module cmdlets don't list with RunspaceConfiguration.Cmdlets so they are missing. A module cmdlet list can be piped into PSRuntimeHosted instance in the cmdlets member to fix the missing cmdlets.

I think I created an new constructor PSRuntimeHosted(snapIns:string[], modules:[])

I forget where I got stuck but the root issue is RunspaceConfiguration.Cmdlets don't list the module commands so they have to be added to the provider with additional effort.
***Edit
Actually now that I sent this message I remember where the conflict lives:
An easy path would be to configure the InitialSessionState but a runspace can be constructed with either a RunspaceConfig or an InitialSessionState. So I hacked it in by merging the runspace cmdlets from 2 runspaces, first being the original with configuration and another that gets created with initialsessionstate

@sergey-tihon sergey-tihon self-assigned this Jun 25, 2015
sergey-tihon added a commit to sergey-tihon/FSharp.Management that referenced this issue Jul 6, 2015
* Added ability to call Azure PowerShell cmdlets. fsprojects#47
* New type inference approach for PS TP and new tests
* Added paket dependency to FSharp.TypeProviders.StarterPack
@sergey-tihon
Copy link
Member

Please try latest package from NuGet

type PS = PowerShellProvider< "Azure" >

image

@sergey-tihon
Copy link
Member

Please test it and reopen this issue if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants