Events
17 Mar, 9 pm - 21 Mar, 10 am
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The Orleans PowerShell client module is a set of PowerShell Cmdlets that wraps the GrainClient. It provides a set of convenient commands, that make it possible to interact with not just the ManagementGrain
but any IGrain
just as a regular Orleans application can by using PowerShell scripts.
These cmdlets enable a series of scenarios from start maintenance tasks, tests, monitoring, or any other kind of automation by leveraging PowerShell scripts.
To install this module from the source, you can build using the OrleansPSUtils
project and just import it with:
Import-Module .\projectOutputDir\Orleans.psd1
Although you can do that, there is a much easier and more interesting way by installing it from PowerShell Gallery. PowerShell modules are easily shared, much like Nuget packages, but instead of nuget.org, they are hosted on the PowerShell Gallery.
To install this module from the PowerShell gallery, run the following command in the desired folder:
Save-Module -Name OrleansPSUtils -Path <path>
To install it on your PowerShell modules path (the recommended way), run:
Install-Module -Name OrleansPSUtils
If you plan to use this module on an Azure Automation, use this link.
Regardless of the way you decide to install it, you need to import the module on the current PowerShell session so the cmdlets get available by running this:
Import-Module OrleansPSUtils
Important
In case of building from source, you must import it as suggested on the Install the module section by using the path to the .psd1
instead of using the module name since it will not be on the $env:PSModulePath
PowerShell runtime variable. It is highly recommended that you install from PowerShell Gallery instead.
After the module is imported (which means it is loaded on PowerShell session), you will have the following cmdlets available:
Start-GrainClient
Stop-GrainClient
Get-Grain
This module is a wrapper around GrainClient.Initialize() and its overloads.
The same as a call to GrainClient.Initialize(), which will look for the known Orleans client configuration file names:
Start-GrainClient [-ConfigFilePath] <string> [[-Timeout] <timespan>]
The preceding command will use the provided file path as in GrainClient.Initialize(filePath)
.
Start-GrainClient [-ConfigFile] <FileInfo> [[-Timeout] <timespan>]
The preceding command will use an instance of the FileInfo class representing the config file just as GrainClient.Initialize(fileInfo)
.
Start-GrainClient [-Config] <ClientConfiguration> [[-Timeout] <timespan>]
The preceding command will use an instance of a ClientConfiguration like in GrainClient.Initialize(config)
.
Start-GrainClient [-GatewayAddress] <IPEndPoint> [[-OverrideConfig] <bool>] [[-Timeout] <timespan>]
The preceding command takes an Orleans cluster gateway address endpoint.
Tip
The Timeout
parameter is optional and if it is informed and greater than TimeSpan.Zero, it will call GrainClient.SetResponseTimeout(TimeSpan) internally.
To stop the GrainClient
, call the following command:
Stop-GrainClient
The preceding command takes no parameters and when called, if the GrainClient
is initialized will be gracefully uninitialized.
To get a Grain
, this cmdlet is a wrapper around GrainClient.GrainFactory.GetGrain<T>()
and its overloads. The mandatory parameter is -GrainType
and the -XXXKey
for the current Grain key types supported by Orleans (string
, Guid
, long
) and also the -KeyExtension
that can be used on Grains with compound keys.
This cmdlet returns a grain reference of the type passed by as a parameter on -GrainType
. As an example on calling MyInterfacesNamespace.IMyGrain.SayHelloTo
grain method:
Import-Module OrleansPSUtils
$configFilePath = Resolve-Path(".\ClientConfig.xml").Path
Start-GrainClient -ConfigFilePath $configFilePath
Add-Type -Path .\MyGrainInterfaceAssembly.dll
$grainInterfaceType = [MyInterfacesNamespace.IMyGrain]
$grainId = [System.Guid]::Parse("A4CF7B5D-9606-446D-ACE9-C900AC6BA3AD")
$grain = Get-Grain -GrainType $grainInterfaceType -GuidKey $grainId
$message = $grain.SayHelloTo("Gutemberg").Result
Write-Output $message
Hello Gutemberg!
Stop-GrainClient
There are additional cmdlets not discussed, but there is support for Observers, Streams and other Orleans core features more natively on PowerShell.
Note
The intent is not to reimplement the whole client on PowerShell but instead, give IT and DevOps teams a way to interact with the grains without needing to implement a .NET application.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
17 Mar, 9 pm - 21 Mar, 10 am
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Creare la prima app Orleans con ASP.NET Core 8.0 - Training
Informazioni su come creare app distribuite native del cloud con Orleans.