0

I am trying to auto login to Azure azcopy from ubuntu 18.04

using the format : ( the normal way works fine )

azcopy -login --tenant-id=yourtenantid

as suggested in this post : AzCopy login fails

but it is not possible, as the command prompt says :

To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXX to authenticate.

what am I missing here ? Is this possible using this method ? if so please give me the correct way to do this.

Thanks. O.

osum
  • 805
  • 2
  • 10
  • 32
  • Could you describe your issue clearly? Did you get the same error with this [post](https://stackoverflow.com/questions/53085003/azcopy-login-fails)? `To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXX to authenticate` is not an error, follow it to do that. – Joy Wang May 16 '19 at 01:37

1 Answers1

3

If you use the command azcopy -login --tenant-id=yourtenantidto login, you must open a browser to enter your username and password. So the command prompt says :

To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXX to authenticate.

Besides, if you want to auto login to Azure azcopy, you use the managed identity to finish authentication. please note that you want to use the way, the VM should be hosted on Azure. The detailed steps are as below.

  1. Enable system-assigned managed identity on your VM enter image description here

  2. Grant your VM access to an Azure Storage a. Navigate back to your created storage account. 

    b. Click the Access control (IAM) link in the left panel.

    c. Click + Add role assignment on top of the page to add a new role assignment for your VM.

    d. Under Role, from the dropdown, select Storage Blob Data Contributor.

    e. In the next dropdown, under Assign access to, choose Virtual Machine.

    g. Next, ensure the proper subscription is listed in Subscription dropdown and then set Resource Group to All resource groups.

    h. Under Select, choose your VM and then click Save. enter image description here

  3. Login to Azure azcopy

./azcopy login --identity

For more details, please refer to

https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-linux-vm-access-storage

https://github.com/Azure/azure-storage-azcopy

Md Farid Uddin Kiron
  • 16,817
  • 3
  • 17
  • 43
  • This is excellent info. The Azure docs do not cover this exact scenario, which seems more practical than the examples in the docs. Thank you. – Doug Allrich Sep 04 '19 at 03:15
  • doesn't work if i need to use azcopy cli with SAS token – Alex Dembo May 10 '23 at 13:35
  • How it would work if the context are different, most importantly, the solution wasn't written for you back in 2019. If you have any specific question better to ask in newer question. – Md Farid Uddin Kiron May 11 '23 at 01:02