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

Microsoft.Graph.Authentication fails to load in Azure Functions with WEBSITE_RUN_AS_PACKAGE #2198

Closed
BHoggs opened this issue Jul 28, 2023 · 1 comment · Fixed by #2206
Closed

Comments

@BHoggs
Copy link
Contributor

BHoggs commented Jul 28, 2023

Describe the bug
When running The Graph SDK module in Azure functions as a package, the authentication module fails to load, causing all other modules to also fail to load.

ERROR: Could not find file 'C:\home\site\wwwroot\.mg'

I have traced the issue to this line of code:

Directory.CreateDirectory(Core.Constants.GraphDirectoryPath);

The issue is that when running WEBSITE_RUN_AS_PACKAGE, the user home directory is read-only, so it fails to create the directory.

Workaround
You can work around this issue by creating a .mg directory in the root of your function project.

To Reproduce
Steps to reproduce the behavior:

  1. Create an Azure function using the powershell 7 runtime on windows, use EP1 plan. (not consumption)
  2. Create a azure powershell function using the VS Code powershell extension
  3. Edit requirements.psd1 to include a few v2 Graph modules, including Microsoft.Graph.Authentication
  4. Add Import-Module Microsoft.Graph.Authentication somewhere in your function
  5. Deploy to function app using VS Code
  6. Test function, see errors.

Expected behavior
Module should load without errors

Module Version
2.2.0

Additional context
I'm wondering if #2133 is also related to this issue. Azure automation potentially obfuscating this error?

@ghost ghost added the ToTriage label Jul 28, 2023
@BHoggs
Copy link
Contributor Author

BHoggs commented Jul 28, 2023

Slight addition from further testing, the reproduction steps only seem to work on a non-consumption app services plan. (used EP1). For whatever reason the error doesn't occur on consumption.

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

Successfully merging a pull request may close this issue.

2 participants