2

I am new in the Powershell and Azure (C/C++ background) world and I want to write a PowerShell script which monitors an Azure Event Hub. One way (and so far the only way I've found) to solve this is by using the .NET classes from Microsoft.​Azure.​Event​Hubs.​Processor. I assume the code to create an instance of the EventProcessorHost class would look something like this:

$eventPHost = [Microsoft.Azure.EventHubs.Processor]::EventProcessorHost($AZR_EVENT_HUB_PATH, $AZR_CONSUMER_GRP_NAME, $AZR_EVENT_HUB_CONNECTION_STR, $AZR_STORAGE_CONNECTION_STR, $AZR_LEASE_CONTAINER_NAME);

However, the namespace Microsoft.Azure.EventHubs.Processor is unknown to PowerShell and it seems that I am doing something wrong or missing something. At this point I am not sure if my code is invalid or I am missing some .NET SDK or something. Also I couldn't find any examples which are similar to this.

Could anyone lead me in the right direction please? I am kind of stuck with no idea in which direction to go.

3
  • Can you copy this DLL in the directory from where you're running the PS script? Commented May 29, 2017 at 12:24
  • Azure has its own selection of Powershell modules. Have you read the docs yet? Commented May 29, 2017 at 12:42
  • @vonPryz Thanks, but these only support the Resource Management for Event Hubs, not allowing them to be monitored. Commented May 29, 2017 at 14:35

2 Answers 2

1

Firstly you need to download .dll into powershell session:

[System.Reflection.Assembly]::LoadFile("c:\script\name.dll")
Sign up to request clarification or add additional context in comments.

2 Comments

Add-Type -AssemblyName is the preferred way to load .Net assemblies.
I get the following console output: GAC Version Location --- ------- -------- False v4.0.30319 C:\Users\abc\.nuget\packages\Microsoft.Azure.EventHubs.Processor\1.0.1\lib\net451\Microsoft.Azure.EventHubs.Process... However, when I try to access [Microsoft.Azure.EventHubs.Processor] it says: "Unable to find type [Microsoft.Azure.EventHubs.Processor]."
1

You can load the assembly using Add-Type: For e.g.

Add-Type -Path "C:\assemblies\name_of_assembly.dll"

1 Comment

Add-Type -Path "<path>" Doesn't work for me: Add-Type : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. I am using PS version 5.1.14393.1198

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.