0

I have a .NET 7 app in a linux environment that has an endpoint "/api/uploads" that accepts a file and saves it to a folder "uploaded". I am trying to get this "uploaded" folder to be mapped to AzureFiles,

I have tried the following mount paths "/uploaded", "wwwroot/uploaded" and "mounts/wwwroot/uploaded" however the files are never saved in AzureFiles but instead are saved to the "wwwroot/uploaded" folder than can be accessed through .scm.azurewebsites.net Screenshot with my current config

I also followed these steps https://learn.microsoft.com/en-us/azure/app-service/configure-connect-to-azure-storage?tabs=portal&pivots=code-windows and still cant get it to work.

When the application starts up I see that the content root path is "/home/site/wwwroot", thats the reason behind my failed attempt with "/mounts/home/site/wwwroot/uploaded"

I have also tried enabling "WEBSITES_ENABLE_APP_SERVICE_STORAGE" according to https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/faqs-app-service-linux

1
  • Add a screenshot of the mapping config in the Portal to your question. Commented Mar 2, 2023 at 14:36

1 Answer 1

0

I am able to upload the for the path success:/home/site/wwwroot/wwwroot

Reference @Tiny Wang @CSharpRocks


            string rootPath = this.Environment.WebRootPath;
            try
            {
                _logger.LogInformation("the root path is :" + rootPath);
                if (file != null && file.Length > 0)
                {
                    var fileName = Guid.NewGuid().ToString() + "_" + name;
                    string uploadFilePath = Path.Combine(rootPath, "images", fileName);

                    await using var stream = new FileStream(uploadFilePath, FileMode.Create);
                    await file.CopyToAsync(stream);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }

            return "success:" + rootPath;
        }
        

enter image description here

enter image description here

  • Make sure that the URL name is replaced with app service name.

enter image description here

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.