0

I'm working on a project to move a dotnet application from Virtual Machine to App Service.

The code has been moved already using deployment center and the pages loads up. But in the backend there are alot of file transfers happening where the folder paths are like D:/AppRoot/FolderA etc.

I have created a storage account and mapped the exact folder structure there as it's in the VM. From App Service configuration I have mounted the Azure Files Share. So it's now /mounts/AppRoot which contains the folders.

Now is it possible for me to direct the application to use the mounted path by updating the folder paths in the web.config file from anything that has D:/AppRoot/ to /mounts/AppRoot ?

Any advice on this will be a great help.

Tried playing around with the syntaxes and path directories. Nothing worked.

I tried googling around, Checking alot of Forums but no one seems to have suggested a final solution for this.

zeeka
  • 3
  • 2

1 Answers1

0

Yes, you can update the folder paths in the web.config file to use the mounted path.

For this, you need to replace the path D:/AppRoot/ with /mounts/AppRoot/ in the web.config file. And this allows the application to access the files from the mounted path.

enter image description here

  • Open web.config file in an editor. You can access the web.config file from the App Service Editor in the Azure portal.

    enter image description here

  • Search for the folder paths that start with D:/AppRoot/. You can use the search function in the text editor to find all instances of the folder paths.

enter image description here

  • Replace the folder paths with /mounts/AppRoot/. And save the web.config file.
<appSettings>  
    <add key="FolderPath" value="/mounts/AppRoot/FolderA" />
  </appSettings>

Now the application be able to access the files from the mounted path.

For more information refer to Mount Azure file share on Windows and Configuring apps.

Rajesh Mopati
  • 1,329
  • 1
  • 2
  • 7
  • Thanks @Rajesh, I have tried this. But it gets me to an error. even though I mentioned the path starting from /mounts/AppRoot/ , Application tries to access it by adding C:/ as a prefix infront of it. ie, C:/mounts/AppRoot/.... As such a path does not exist, it hence throws an access denied error. – zeeka May 12 '23 at 08:20
  • Below is the full error Server Error in '/' Application. Access to the path 'C:\mounts\AppRoot\FilePath\Filename' is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access to the path 'C:\mounts\AppRoot\FilePath\Filename' is denied. – zeeka May 12 '23 at 08:21
  • The application is still trying to access the local path instead of the mounted path. Use relative path instead of an absolute path in the web.config file, if the mounted path is /mounts/AppRoot/FolderA, you can use ../FolderA instead of /mounts/AppRoot/FolderA in the web.config file. – Rajesh Mopati May 12 '23 at 08:26
  • The mounted path is accessible from the App Service and check the necessary permissions are set up. You can check the permissions by going to the storage account and selecting the File share. Then, select the Access control (IAM) tab and make sure that the necessary roles are assigned to the App Service. – Rajesh Mopati May 12 '23 at 08:27
  • I have tried this also but doesn't work. Even when I ignore the root path and mention only the Folder Name in Key, Web app still appends Driveletter C:/ infront of it and makes it C:/Foldername and then fails as such a path doesn't exist. – zeeka May 12 '23 at 13:17
  • For anyone that might run into such an issue in the past, The steps mentioned by Rajesh worked just fine for me. It didnt work earlier due to some other issues on my application which is resolved now. Thanks to @Rajesh M, Without your reply I'd have lost hope and went for other methods. – zeeka May 17 '23 at 14:24