Skip to content
This repository was archived by the owner on Sep 7, 2023. It is now read-only.
This repository was archived by the owner on Sep 7, 2023. It is now read-only.

MsalCacheHelper.UserRootDirectory returns empty string when run in Azure function environment #202

Open
@ghost

Description

When running the following code in an azure function environment:

var storageProperties = new StorageCreationPropertiesBuilder(_cacheFileName, MsalCacheHelper.UserRootDirectory).Build();
MsalCacheHelper cache = await MsalCacheHelper.CreateAsync(storageProperties).ConfigureAwait(false);

I hit the following exception:

Exception: System.ArgumentException: Path cannot be the empty string or all whitespace. (Parameter 'path')
   at System.IO.Directory.CreateDirectory(String path)
   at Microsoft.Identity.Client.Extensions.Msal.CrossPlatLock..ctor(String lockfilePath, Int32 lockFileRetryDelay, Int32 lockFileRetryCount)
   at Microsoft.Identity.Client.Extensions.Msal.MsalCacheHelper.CreateCrossPlatLock(StorageCreationProperties storageCreationProperties)
   at Microsoft.Identity.Client.Extensions.Msal.MsalCacheHelper.CreateAsync(StorageCreationProperties storageCreationProperties, TraceSource logger)

While this code had run fine locally, we hit exceptions 100% of the time after deploying this code to our azure function. After some investigations, we realized that MsalCacheHelper.UserRootDirectory returns an empty string when in an azure function environment.

The MsalCacheHelper.UserRootDirectory code mentions that this value "Gets the user's root directory across platforms." It would be great if the azure function platform was included here!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions