Skip to content
This repository has been 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 opened this issue Feb 1, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ghost
Copy link

ghost commented Feb 1, 2023

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!

@bgavrilMS bgavrilMS added enhancement New feature or request good first issue Good for newcomers labels Feb 2, 2023
@bgavrilMS
Copy link
Member

Good point, this helper was only ever tested on Windows, Mac and Linux.

We'd appreciate a contribution to get this to work on Azure Functions, I'm not even sure if "root dir" concept exists in this case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant