question

RajD-9527 avatar image
0 Votes"
RajD-9527 asked SumanthMarigowda-MSFT commented

Replace shared network drive with Azure Fileshare

Greetings!!!

We are planning to replace the on-premise shared network drive with an Azure Fileshare. For instance if we have a file on on-premise shared network drive and the UNC path is "\\onpremshare\datashare\path\test.txt", Now, We would like to replace this path to an Azure Fileshare and the UNC path would be "\\azurefileshare.file.core.windows.net\datalakeshare\path\test.txt".

I run the below Powershell script using the SMB protocol

 $connectTestResult = Test-NetConnection -ComputerName azurefileshare.file.core.windows.net -Port 445
 if ($connectTestResult.TcpTestSucceeded) {
     # Save the password so the drive will persist on reboot
     cmd.exe /C "cmdkey /add:"azurefileshare.file.core.windows.net" /user:"localhost\azurefileshare" /pass:"jshdahdfhhdhcuhkey""
     # Mount the drive
     New-PSDrive -Name Z -PSProvider FileSystem -Root "\\azurefileshare.file.core.windows.net\datalakeshare" -Persist
 } else {
     Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
 }

This approach works on my machine but when I try to replace the file path in my application code I run into error saying the specified path does not exist. I'm not sure on how to make this change global as long as the users or the application has access control to the Azure Fileshare. Is there a way for applications or others to connect to it without having to key in user name and password. Similar to how we access the on-premise shared network drive as long as one has rights.

Also, Is there a way to write this code in C#?

Could you please point me in the right direction.

Thank you

dotnet-csharpwindows-server-powershellazure-files
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RajD-9527 Firstly, apologies for the delay in responding here I am looking into this thread!

0 Votes 0 ·

0 Answers