-
Notifications
You must be signed in to change notification settings - Fork 194
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
Error when creating context using M365 group GUID #1114
Comments
@JakeStanger : when you create the site in step 2 you get back the |
This is because steps 2-4 are all separate Azure Functions, triggered by an orchestrator. The orchestrator can provide the factory since it's automagically injected, but functions can only take/return serializable data as arguments and (I think at least) there is no guarantee field values on the class level will persist if set by functions for similar reasons. In short, the context is disposed of at the end of each function, so a new context is required at the start of each. |
@JakeStanger : so the failure comes from https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core/Services/Core/PnPContextFactory.cs#L467 and https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core/Services/Core/Http/MicrosoftGraphClient.cs#L67-L74. How are you added the note: I've just pushed a small update that only updates the base address when there's a true change, this might help already. This update will be part of the next nightly release (version 1.8.114 or higher) |
The factory is created in builder.Services.AddPnPCore(options =>
{
options.PnPContext.GraphFirst = true;
// snip - auth code
}); This means it can get automatically injected into the orchestrator class constructor: public sealed class Orchestrator
{
private readonly IPnPContextFactory _contextFactory;
public Orchestrator(IPnPContextFactory contextFactory)
{
_contextFactory = contextFactory;
}
// snip
} We then have access to the factory from each function via the
Not from the same function. The previous function creates the team using the SP admin context, which I could arguably be doing in the failing function for consistency's sake anyway.
Cool, cheers! I will try this once it has been built and I have a chance and let you know how it goes |
@JakeStanger : did things improve with the extra check in the code? |
Hey, sorry got distracted by other bits & only just tested this - it looks to have worked :) |
Category
Describe the bug
When creating a context object, using an M365 group GUID, the library may throw an error:
This appears to be because the library is incorrectly tracking whether the base address has been updated when creating a Graph client.
Steps to reproduce
I am not sure if the bug is specific to this case, but here's how I encountered it:
*necessary, since the operations are split across multiple orchestrated 'activity' functions.
Expected behavior
The context should be created succesfully, or return a meaningful error if provided bad input(s).
Environment details (development & target environment)
The text was updated successfully, but these errors were encountered: