# Copy File from Azure Storage mapped drive to VM

**URL:** <https://forum.ansible.com/t/copy-file-from-azure-storage-mapped-drive-to-vm/38339>\
**Category:** Ansible Project\
**Tags:** azure, windows\
**Created:** [August 16, 2023, 9:31am UTC](https://forum.ansible.com/t/copy-file-from-azure-storage-mapped-drive-to-vm/38339 "2023-08-16T09:31:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brad3](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Brad3](https://forum.ansible.com/u/Brad3)\
**Post date:** [August 16, 2023, 9:31am UTC](https://forum.ansible.com/t/copy-file-from-azure-storage-mapped-drive-to-vm/38339/1 "2023-08-16T09:31:05Z")

</div>

Hi,

I’m trying to get Ansible to copy files from a mapped azure drive locally but I keep getting the below error:

fatal: [192.168.1.193]: FAILED! =\> {“changed”: false, “dest”: “C:\Temp\dotNET53”, “msg”: “Cannot copy src file: ‘Z:\Software\Microsoft\dotNET3\microsoft-windows-netfx3.cab’ as it does not exist”, “src”: “Z:\Software\Microsoft\dotNET3\microsoft-windows-netfx3.cab”}

My code is:

- name: Copy dotNET 3.5 CAB File to Server  
win\_copy:  
src: Z:\Software\Microsoft\dotNET3\microsoft-windows-netfx3.cab  
dest: “{{ Generic\_Temp\_Path }}\dotNET53”  
remote\_src: true

All the online reading I’ve done seems to point to double hop creds being the issue. But I’m a bit stuck since the authentication to the mapped drive is using the storage key as the pass and localhost\storageaccountname as username.

If I log in as ansible\_user then run net use shows the drive mapped. I can’t switch to Azure AD auth as the boxes may or may not be joined.

Has anyone got any suggestions? I didnt think this would be so complex haha!

Thanks,

Brad.

---

<div class="post-metadata">

**Author:** ![atul\_mohan](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@atul\_mohan](https://forum.ansible.com/u/atul_mohan)\
**Post date:** [August 19, 2023, 5:18pm UTC](https://forum.ansible.com/t/copy-file-from-azure-storage-mapped-drive-to-vm/38339/2 "2023-08-19T17:18:02Z")

</div>



---

<div class="post-metadata">

**Author:** ![Brad3](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Brad3](https://forum.ansible.com/u/Brad3)\
**Post date:** [August 22, 2023, 10:36am UTC](https://forum.ansible.com/t/copy-file-from-azure-storage-mapped-drive-to-vm/38339/3 "2023-08-22T10:36:14Z")

</div>

Im afraid that didnt work. Still getting the same issues.

I’ve been playing with win\_shell also and still same issue. Im actually executing two roles in my playbook. The first role is Add storage creds & map drive & the second is the copy file.

- name: Add storage creds & map drive  
block:

- name: Adding creds for mapped drive  
win\_credential:  
name: [storage.file.core.windows.net](http://storage.file.core.windows.net)  
type: domain\_password  
username: localhost\storage  
secret: “{{ storage\_account\_keys.json[‘keys’].0.value }}”

- name: Map drive  
win\_mapped\_drive:  
letter: Z  
path: \storage.file.core.windows.net\cmdb  
username: localhost\storage  
password: “{{ storage\_account\_keys.json[‘keys’].0.value }}”  
vars:  
ansible\_become: yes  
ansible\_become\_method: runas  
ansible\_become\_user: “{{ ansible\_user }}”  
ansible\_become\_password: “{{ ansible\_password }}”

- name: Copy File  
#win\_shell: Copy-Item Z:\Software\Microsoft\dotNET3\microsoft-windows-netfx3.cab -Destination “{{ Generic\_Temp\_Path }}\dotNET53\microsoft-windows-netfx3.cab”  
win\_shell: Copy-Item \storage.file.core.windows.net\cmdb\Software\Microsoft\dotNET3\microsoft-windows-netfx3.cab -Destination “{{ Generic\_Temp\_Path }}\dotNET53\microsoft-windows-netfx3.cab”  
vars:  
become: true  
become\_method: runas  
#become\_user: SYSTEM  
become\_user: “{{ ansible\_user }}”  
become\_password: “{{ ansible\_password }}”  
#become\_flags: logon\_type=new\_credentials logon\_flags=netcredentials\_only  
become\_flags: logon\_type=interactive logon\_flags=netcredentials\_only

If I login as {{ ansible\_user }} and run net use without UAC and I can see the Z:. Yet Ansible will not copy the file. Ive played with various become flags and all fail.

Any ideas?

Cheers!
