1

Have a Windows service running in a Azure Windows Server 2022 VM, also mapped the Azure file share to a Windows drive Z:\ in this VM according to this tutorial, the Windows service is trying to create a folder ABC in the Z:\test folder, but it didn't work, how to fix this?

Directory.CreateDirectory("Z:\\test\\ABC");

enter image description here

J.W
  • 671
  • 7
  • 23

1 Answers1

1

I tried to reproduce the same in my environment and got below results:

I have storage account with one file share named srifileshare like below:

enter image description here

In that file share, I added one directory named test like below:

enter image description here

To map file share to Windows VM, I got Powershell script from here:

enter image description here

When I ran the above script in my Windows VM, it mapped to file share successfully like below:

enter image description here

When I checked the same in File Explorer, Z drive is available with test folder in it like below:

enter image description here

When I tried to create ABC folder inside test folder, it created successfully like below:

enter image description here

I checked the same in Portal where ABC directory is created in file share successfully like below:

enter image description here

Note that, only UNC paths are supported to create a directory on a remote computer or on a share

In your case, try changing the path from Z:\\test\\ABC to below:

Directory.CreateDirectory("\\\\<storageaccountname>.file.core.windows.net\\<storagefilesharename>\\test\\ABC");

Reference:

Directory.CreateDirectory Method (System.IO) Microsoft

Sridevi
  • 10,599
  • 1
  • 4
  • 17
  • 1
    Thanks @Sridevi, it works now after changing the path to network format path :) – J.W Jan 26 '23 at 03:39