I want to run shell script on Linux using azure-cli (az command) that login to Azure without entering password and run other azure-cli commands without login again.
First, I once run 'az login', it create a .azure under my home directory, who save all the login information and give me ability to run other az command without login again. After few weeks/months it stop working, running 'az login' again solved the problem.
What it the best way to keep login to azure from a script without entering password?
Thanks.
The recommended way to do unattended logins from scripts is by using a service principal with a certificate.
See e.g. Create an Azure service principal with Azure CLI 2.0 for instructions on how to set up the certificate and service principal and how to do the actual login.
The above link has instructions for settings this up for AzureRM PowerShell as well as for Azure CLI.