How to use cms-content for Storefront from the network resource

For some reason, you may need to place a cms-content directory on a network share. If you are a developer and run the storefront in debugging or as a console application, you will not have any problems with this. Just your current user should have access to this network resource. But if your application hosts into IIS, access problems to network resource may occur.

In both cases, it is recommended to use the UNC path to the folder in the appsettings.json file. Do not use mapped drive! This causes performance issues.

Also be careful. The UNC path must be specified with an escaped slash character.

For example:

“ContentConnectionString”: “provider=LocalStorage;rootPath=\\server\shared\cms-content”

In ASP.NET, developers are able to use a virtual directory within IIS website for storing static resources in the directory outside of the application, including on a network resource. Unfortunately, with ASP.NET Core, this solution doesn’t work. A virtual directory in IIS won’t be recognized and users will see a 404 error. Kestrel runs beneath IIS (using the HttpPlatformHandler module) and IIS brokers only the requests to it, so Kestrel does not know about virtual directories from IIS.

The solution to access this folder is to run the webserver’s AppPool as the identity that can access the share. This way is safer because the credentials are stored securely in the IIS config (rather than in code or in config files). For this, you just need to create a local user on both machines and ensure they both have the same name and password. You can also use Active Directory Domain Account, just make sure, that you correctly type in the name and domain. So, the full instruction is as follows,

  1. On your IIS machine, create a user and set a password.
  2. On your network share machine, create a user with the same name and password as in step 1.
  3. Give permission to a shared folder to this user.
  4. In IIS Manager, select the application pool that your web app uses or create a new one if you use the default one.
  5. Click on “Advanced Settings” in the right Actions bar. Under Process Model, click on the “Identity” value and select “Custom account”.
  6. Click on the “Edit” and enter user name and password from step 1. If you enter all information correctly, the pop-up will be closed successfully without any error messages.
  7. After that stop your Web Site.
  8. Back again to your application pool and click on the “Recycle”.
  9. Start your Storefront Web Site.
1 Like

@trueboroda Great article, any info on how to configure this in Azure Cloud?

For Azure App is the more preferred approach in using Azure Blob Storage. You must first create a blob storage resource on your Azure Cloud space. This links can be helpful: Recommended production configuration for Microsoft Azure
Deploy Platform from GitHub to Microsoft Azure
Deploy Storefront from GitHub to Microsoft Azure
But if it is really necessary this document can help. https://docs.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet