login to Azure from a script
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.