Home > Enterprise >  Unable to create a new folder in Azure file share by a Windows service running in Azure VM
Unable to create a new folder in Azure file share by a Windows service running in Azure VM

Time:01-26

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 enter image description here

CodePudding user response:

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

  • Related