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

Start trying to remove graph api sdk dependency #1003

Open
wants to merge 76 commits into
base: dev
Choose a base branch
from

Conversation

quails4Eva
Copy link

Reduce dependency on Microsoft.Graph NuGet package
Based on discussion in #660
#660 (comment)

var subscriptionModel = MapGraphEntityToModel(subscription);
return subscriptionModel;
}).GetAwaiter().GetResult();
var response = JToken.Parse(responseAsString);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting string to Model seems like it could be an extension method?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also tagging @KoenZomers as he wrote a lot of the original code

@jansenbe jansenbe self-assigned this Apr 10, 2024
var subscriptionModel = MapGraphEntityToModel(subscription);
return subscriptionModel;
}).GetAwaiter().GetResult();
var response = JToken.Parse(responseAsString);
Copy link
Contributor

@jansenbe jansenbe Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quails4Eva : would recommend using System.Text.Json over Newtonsoft

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've done this. I copied the newtonsoft code from elsewhere in the project, but I think this should be equivalent for system.text.json . It needed the package version updating for .net standard. I've changed it to use the same version for each target framework as I don't think system.text.json is tied to framework versions as some other packages are

@quails4Eva
Copy link
Author

Next time I have some free time to look at this I'll try and replace the other usages in SubscriptionsUtility

@quails4Eva
Copy link
Author

I started adding some async http bits to maintain where async was already being used, but then I realised that the async usage was all wrapped in Task.Run so probably not really helping anything. I can undo that if you'd rather it be put back.

GivenName = usr.GivenName != null ? usr.GivenName : string.Empty,
Surname = usr.Surname != null ? usr.Surname : string.Empty,
Email = usr.Mail != null ? usr.Mail : string.Empty,
MobilePhone = usr.MobilePhone != null ? usr.DisplayName : string.Empty,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the behaviour change for MobilePhone and Job Title. Is it right that these were returning the Display Name instead?

@quails4Eva
Copy link
Author

@jansenbe I'm looking at what's needed to replace the graph api sdk usage in the UsersUtility class and I think it would involve copying a bunch of dto classes from the graph sdk as currently these can be selected in as additional properties. I can do this, but I'm wondering how much value the methods on this class add as they just seem to be light wrappers over the underlying graph sdk methods? Would it make sense to just delete this class? Alternatively I could keep the methods, but remove the ability to select additional properties, as it seems to me like anyone doing that may as well just use the underlying graph sdk. I know this would be a breaking change, but it would save quite a bit of work and the methods don't seem like they add much to the framework, unless I'm missing something.

I've just used the System.Text.Json ability to store overflow properties in a dictionary, they'll be whatever type that uses. It's still a breaking change as the old version could return objects from the Graph Sdk, but not much that can be done about that when we're removing Graph Sdk.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSGraph package reference is still in here, is this intended?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that was an oversight from me. I've removed it now.
I also removed Microsoft.Graph.Core and it still builds, though I can add that back in if it causes issues.

@plamber
Copy link

plamber commented Jan 13, 2025

Hi @quails4Eva, @matijahanzic, @jansenbe,

While running an export of a Communication site template using the code below, we are now encountering the following failure:

```
public Stream? GetProvisioningTemplateStream(ClientContext context, Handlers handlers)
{
    handlers &= ~Handlers.SupportedUILanguages;
    handlers &= ~Handlers.PropertyBagEntries;
    handlers &= ~Handlers.SiteSecurity;
    handlers &= ~Handlers.WebSettings;
    handlers &= ~Handlers.SearchSettings;
    handlers &= ~Handlers.WebApiPermissions;
    handlers &= ~Handlers.Tenant;
    handlers &= ~Handlers.ExtensibilityProviders;
    handlers &= ~Handlers.ApplicationLifecycleManagement;
    handlers &= ~Handlers.SyntexModels;
    handlers &= ~Handlers.ImageRenditions;
    handlers &= ~Handlers.CustomActions;
    handlers &= ~Handlers.ComposedLook;
    handlers &= ~Handlers.Workflows;
    handlers &= ~Handlers.TermGroups;
    handlers &= ~Handlers.Publishing;
    handlers &= ~Handlers.Files;
    handlers &= ~Handlers.SiteFooter;
    handlers &= ~Handlers.Theme;

    ProvisioningTemplateCreationInformation creationInformation = new(context.Web)
    {
        PersistPublishingFiles = (handlers & Handlers.Pages) == Handlers.Pages,
        IncludeAllClientSidePages = (handlers & Handlers.Pages) == Handlers.Pages,
        HandlersToProcess = handlers,
        IncludeContentTypesFromSyndication = false,
    };

    context.RequestTimeout = Timeout.Infinite;
    return XMLPnPSchemaFormatter.LatestFormatter.ToFormattedTemplate(context.Web.GetProvisioningTemplate(creationInformation));
}
```

Error Message:

```
System.MissingMethodException: Method not found: 'PnP.Core.Model.SharePoint.IPage PnP.Core.Model.SharePoint.IWeb.NewPage(PnP.Core.Model.SharePoint.PageLayoutType, PnP.Core.Model.SharePoint.EditorType)'.

ObjectClientSidePages.ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
SiteToTemplateConversion.ApplyRemoteTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation provisioningInfo, Boolean calledFromHierarchy, TokenParser tokenParser) line 457
WebExtensions.ApplyProvisioningTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation applyingInformation) line 1182
```

At this point, it’s unclear to me if this issue is related to the recent changes.

I’ll keep an eye out for any further details or patterns and update you if I find anything.

We were able to identify the issue causing this, I did a wrong reference of this PR my code. Sorry for the false alarm.

Cheers

@tonipohl
Copy link

So, when will this fix / update be available as PnP Nuget package? Checked today, Graph client is still included.
Asking for a friend. ;)
Thx, Toni

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

Successfully merging this pull request may close these issues.

5 participants