Please make sure you have assigned the Contributor role to your user account before performing operation so as to be authorized to your Azure Storage account.
For az login
try to create a service principal
az ad sp create-for-rbac --role xxx
Then you can log in with the service principal with
az login --service-principal
or try also to create certificate and then login as shown here azure cli - az login with certificate protected with password - Stack Overflow
If you set an environment variable by using the command line, that
variable will be readable in your command line history
Reference :azcopy login | Microsoft Docs
Please check this way
Log in as a service principal by using a client secret: Set the environment variable AZCOPY_SPA_CLIENT_SECRET to the client secret for secret based service principal auth.
azcopy login --service-principal --application-id <your service principal's application ID>
or
azcopy login --service-principal --application-id "$APP_ID" --tenant-id "$TENANT_ID"
if [[ $? -gt 0 ]]
then
echo "azure copy account login failed"
else
echo "azure copy account login is successful"
fi
0 exit status means the command was successful without any errors. A non-zero exit status means command was a failure.
References:
- azure - How to handle AZcopy failed file transfers - Stack
Overflow
- How to Copy All Containers along with Blobs from one Azure storage
account to other storage account - Stack Overflow
- Use data transfer tools in Azure Stack Hub Storage - Azure Stack
Hub | Microsoft Docs