Hello
I am trying to convert my GUI application from AzureRm to Az module. I've re-compiled the code successfully. However, when GUI is executing step Connect-AzAccount, after login prompt it simply freezes. i.e. it prompts for Azure login/MFA but after successful authentication it just stays as-is.
If i use AzureContext.json file as login, then other Az commands work fine in application. So issue is specific to Connect-AzAccount. I found below issue over github which might be related.
https://github.com/Azure/azure-powershell/issues/8476
Is anyone else experiencing similar issue and if any workaround available?
Thank You
Ajay Kundnani
Connect-AzAccount command not executing in Sapien GUI Application
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Connect-AzAccount command not executing in Sapien GUI Application
From GitHub the issue appears to be with the module and will have to wait for a fix to be released as noted in the bug report.
Re: Connect-AzAccount command not executing in Sapien GUI Application
Thanks Jvierra
Checking if others might be facing similar issue or if any workaround available perhaps
Checking if others might be facing similar issue or if any workaround available perhaps
Re: Connect-AzAccount command not executing in Sapien GUI Application
I am also seeing the hanging form issue when using Connect-AzAccount -Credentials $creds.
I am using Az 2.8.0 with Ac.Accounts 1.6.3 module.
Using Connect-AzAccount -UseDeviceAuthentication shows the url in the output which then works if the code is entered into the browser. Not really a solution but it shows that authentication is otherwise working.
I am using Az 2.8.0 with Ac.Accounts 1.6.3 module.
Using Connect-AzAccount -UseDeviceAuthentication shows the url in the output which then works if the code is entered into the browser. Not really a solution but it shows that authentication is otherwise working.
Re: Connect-AzAccount command not executing in Sapien GUI Application
According to GitHub project this appears to be being addressed, There have been a number of bug posts concerning this and other issues with the module hanging.
Re: Connect-AzAccount command not executing in Sapien GUI Application
I've come up with a crude workaround:
if (Test-Path -Path 'C:\temp\azcontext.json')
{
$null = Import-AzContext -Path 'C:\temp\azcontext.json'
}
else
{
$connectazaccount = { Save-AzContext -Profile (Connect-AzAccount -Credential $using:credentials) -Path 'C:\temp\azcontext.json' }
$null = Start-Job -ScriptBlock $connectazaccount -Name 'connectazaccount'
while ((Get-Job -Name 'connectazaccount').State -eq 'Running') { Start-Sleep -Seconds 1 }
$null = Import-AzContext -Path 'C:\temp\azcontext.json'
$null = Remove-Job -Name 'connectazaccount' -Force -ErrorAction SilentlyContinue
}
if (Test-Path -Path 'C:\temp\azcontext.json')
{
$null = Import-AzContext -Path 'C:\temp\azcontext.json'
}
else
{
$connectazaccount = { Save-AzContext -Profile (Connect-AzAccount -Credential $using:credentials) -Path 'C:\temp\azcontext.json' }
$null = Start-Job -ScriptBlock $connectazaccount -Name 'connectazaccount'
while ((Get-Job -Name 'connectazaccount').State -eq 'Running') { Start-Sleep -Seconds 1 }
$null = Import-AzContext -Path 'C:\temp\azcontext.json'
$null = Remove-Job -Name 'connectazaccount' -Force -ErrorAction SilentlyContinue
}
Re: Connect-AzAccount command not executing in Sapien GUI Application
Thanks Salient, this will work for organizational account right, does it supports MFA as well?
I'll test it out from my side too. I am currently also testing -UseDeviceAuthentication along with Az.Accounts v2.0.0-preview. Will post results how it goes.
Thanks !
I'll test it out from my side too. I am currently also testing -UseDeviceAuthentication along with Az.Accounts v2.0.0-preview. Will post results how it goes.
Thanks !
Re: Connect-AzAccount command not executing in Sapien GUI Application
Hello
Quick update, i tested the scriptblock method with no luck. UseDeviceAuthentication I had very little hope either way since it generates code in Shell window which needs to be inserted then manually in browser.
Any additional thoughts please?
Thanks
Ajay
Quick update, i tested the scriptblock method with no luck. UseDeviceAuthentication I had very little hope either way since it generates code in Shell window which needs to be inserted then manually in browser.
Any additional thoughts please?
Thanks
Ajay