Forms which use certain Azure PS commands hang

Support for all customers who have purchased a SAPIEN PowerShell Studio product license. This forum does not offer a response time guarantee.
Forum rules
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Posts: 3
Joined: Mon Mar 03, 2014 9:32 am

Forms which use certain Azure PS commands hang

Post by rbeuthin2 » Mon Oct 02, 2017 12:16 pm

Product, version and build: PowerShell Studio 2017, 5.4.143
32 or 64 bit version of product: 64-bit
Operating system: Windows 7
32 or 64 bit OS: 64-bit

A few other posts have raised this topic (see end of post for links) but seem to have been abandoned with no definitive answer. The problem is that when using certain Azure cmdlets in a form, the form will hang (sometimes, which I'll get to below) whereas using them in a script with no GUI works all the time. The strange thing is, the form does occasionally work. And once it starts working, it keeps working for hours and will then stop working again, usually if you leave it for a few hours and then return.

The problem can be very easily replicated with this code below in a form with a single button:
$creds = Get-Credential
Login-AzureRmAccount -Credential $creds
Get-AzureRmADGroup #This command will hang
Get-AzureRmKeyVault #This command will work

I have tried with STA on/off and v5/v4 and the behaviour is consistent (except for when it mysteriously decides to work for a while). Also tried on Windows 7 and Windows Server 2016 with same result.

In stepping through the code it seems to hang as it enters the AzureRm.Profile.psd1 file at the point where the Debug output says "Using account id <username>".

Any insight/solutions would be very welcome as there is no shortage of GUI-style scripts that you can write once you start using Azure and this is a big roadblock to doing that.

Other posts which touch on same topic:

User avatar
Alexander Riedel
Posts: 6952
Joined: Tue May 29, 2007 4:43 pm

Re: Forms which use certain Azure PS commands hang

Post by Alexander Riedel » Mon Oct 09, 2017 1:19 pm

That is really a question you should pose to the Azure team. Unfortunately we have no access to their code.
Most likely they make an assumption somewhere that the host has a console, which a Windows forms application does not have.
When they try to get access to the console they get a null object and just fail to handle that. But that is really just a guess on my side.
Alexander Riedel
SAPIEN Technologies, Inc.