Forms which use certain Azure PS commands hang

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
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.
This topic is 6 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
rbeuthin2
Posts: 6
Last visit: Mon Jan 11, 2021 12:27 pm

Forms which use certain Azure PS commands hang

Post by rbeuthin2 »

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:
$button1_Click={
$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:
viewtopic.php?f=21&t=10903
viewtopic.php?f=21&t=11626
User avatar
Alexander Riedel
Posts: 8488
Last visit: Mon Apr 15, 2024 3:28 pm
Answers: 20
Been upvoted: 37 times

Re: Forms which use certain Azure PS commands hang

Post by Alexander Riedel »

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.
This topic is 6 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.