Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no TEMP environment variable on Linux azure app service #11389

Closed
keithswright opened this issue Oct 17, 2021 · 2 comments
Closed

There is no TEMP environment variable on Linux azure app service #11389

keithswright opened this issue Oct 17, 2021 · 2 comments

Comments

@keithswright
Copy link

keithswright commented Oct 17, 2021

Which exact Umbraco version are you using? For example: 8.13.1 - don't just write v8

9.0.0

Bug summary

When deploying to azure app service, the advice is to use "EnvironmentTemp" for LocalTempStorageLocation, so that a unique nucache path is created for each instance of the application

The logic to create the temp file paths uses an environment variable called "TEMP" which does not exist on linux app services and the UI of the portal does not allow you add an configuration setting called "TEMP".

Specifics

The logic in question is in:

Umbraco.Cms.Web.Common.AspNetCore.AspNetCoreHostingEnvironment

        public string LocalTempPath
        {
        get
        {
            if (_localTempPath != null)
            {
                return _localTempPath;
            }

            switch (_hostingSettings.CurrentValue.LocalTempStorageLocation)
            {
                case LocalTempStorage.EnvironmentTemp:

                    // environment temp is unique, we need a folder per site

                    // use a hash
                    // combine site name and application id
                    // site name is a Guid on Cloud
                    // application id is eg /LM/W3SVC/123456/ROOT
                    // the combination is unique on one server
                    // and, if a site moves from worker A to B and then back to A...
                    // hopefully it gets a new Guid or new application id?
                    string hashString = SiteName + "::" + ApplicationId;
                    string hash = hashString.GenerateHash();
                    string siteTemp = Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", hash);

                    return _localTempPath = siteTemp;

                default:

                    return _localTempPath = MapPathContentRoot(Cms.Core.Constants.SystemDirectories.TempData);
            }
        }
    }`

Steps to reproduce

Deploy an umbraco site to a linux instance and set the configuration as per the documentation:

https://our.umbraco.com/Documentation/Fundamentals/Setup/Server-Setup/azure-web-apps

Expected result / actual result

Expected:

Umbraco's local cache files are created in a temporary folder on a local disk with a unique file path

Actual:

The files are created, and with a unique file path, but in the following location:

/site/wwwroot/%temp%/UmbracoData/b4a25dca1fb0e8f6a554f275d23a88272c22e2b0/NuCache/

A side effect of this is, I believe that the /home/site/wwwroot folder is on a network drive and so reading and writing will be slower than a local disk.

@bergmania
Copy link
Member

Hmm.. I guess Environment.ExpandEnvironmentVariables("%temp%") could just be replaced by Path.GetTempPath()

bergmania added a commit that referenced this issue Oct 20, 2021
Use Path.GetTempPath instead of %temp% environment variable.
@Zeegaan
Copy link
Member

Zeegaan commented Oct 21, 2021

Thank you for the issue report 🐛

This issue should now be resolved in: #11430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants