authentication - Azure account will timeout and I am unable to re-authenticate in Powershell -
i have written suite of powershell scripts can build out iaas infrastructure using azure resource manager. of these scripts intended run non-interactive continuous integration framework use. in powershell scripts, prior calling command new-azureresourcegroup, first check make sure machine running script authenticated azure running get-azuresubscription , get-azureaccount. if finds not authenticated, run series of cmdlets such import-azurepublishsettingsfile, select-azuresubscription, add-azureaccount , on.
this works fine of time, , able change subscriptions , credentials each time through , script notice change, , point correct subscription , re-authenticate needed. however, once azure account session times out (i think takes 12 hours), none of above work re-authenticate. if run new-azureresourcegroup while in state, receive message "unauthorized".
once happens, thing fix if manually run add-azureaccount, , manually type in credentials. once done, scripts run fine until next timeout.
i have read importing publish settings file alone should work scenario, re-importing file doesn't seem work either. has else been able authenticate azure powershell script after timeout?
i figured out, , own dumb mistake. our company has several azure subscriptions, , in effort not log in , out of subscriptions time, setup own azure account co-admin on of them. unfortunately me, created 2 azureautomation accounts...one under azure account, , 1 under subscription owner account. resulted in 2 accounts similar different:
azureautomationuser@adminnamecompanyname.onmicrosoft.com azureautomationuser@mynamecompanyname.onmicrosoft.com
one setup admin on subscription , other not. non-admin 1 using in powershell script, unauthorized message valid.
Comments
Post a Comment