msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Access delta link from delta cmdlets

Open maisarissi opened this issue 2 years ago • 9 comments

Customers can use the delta commands to list all changes on a resource from start to finish and the nextLink will be followed to the end as stated at Use delta query to track changes in Microsoft Graph data - Microsoft Graph | Microsoft Learn.

However, today there is no way to access the deltaLink, that's returned on the last page to track changes from "last delta call".

I want to be able to access the deltaLink as well as passing it to the delta command, so I can track the changes from the last call.

maisarissi avatar Jun 02 '23 21:06 maisarissi

@peombwa @timayabi2020 can you validate whether AutoREST supports it?

maisarissi avatar Jun 02 '23 21:06 maisarissi

~The CSDL will also need to be annotated to signal to SDKs that delta functions support deltaToken query parameter - https://github.com/microsoftgraph/msgraph-metadata/issues/354.~

peombwa avatar Jun 02 '23 22:06 peombwa

Per the discussion at https://github.com/microsoftgraph/msgraph-metadata/issues/354#issuecomment-1644373358, the SDK should instead add support -DeltaLink parameter, which takes the @odata.deltalink value from the previous call:

Get-Mg*Delta -DeltaLink $link # value from the odata.deltalink property of the previous call

The implementation should ensure:

  • @odata.deltalink property from the previous request is available to the caller. This can be a global variable, etc.
  • Get-Mg*Delta -DeltaLink parameter set should only support -DeltaLink parameter to avoid sending malformed request URIs. Query parameters are specified once in the initial request. Microsoft Graph automatically encodes the specified parameter into the @odata.deltaLink returned in the response.

peombwa avatar Jul 20 '23 23:07 peombwa

Hey folks, just adding my 2c - been talking over this with @SteveMutungi254 since May and then it got kinda forgotten for a while, as I mistakenly popped the bug in ADO and not here :) Got a bit of flak from customers on this as they were building automation around the delta functionality. Given them this sample as a workaround, but certainly seems an overlooked capability ;)

@CarolKigoonya

pgarm avatar Aug 30 '23 15:08 pgarm

Copying from ADO

Solution options

  1. Implement session/module variable to cache deltaLink, and implicitly use it on subsequent Get-MgXxxxDelta executions. Downside - only persistent within session, so not suitable for scheduled jobs (based on customer conversations, this is mostly used in non-interactive automation).
  2. Add explicit -DeltaLinkVariable parameter to push the link into current scope so user can handle the saving/retrieval themselves, and explicit -DeltaLink parameter to use the link in subsequent calls.

(ideally - both options to give users flexibility) Instead of full deltaLink, can save just the deltaToken (marginally reduces memory/storage use, but makes it harder to reuse the link elsewhere.

pgarm avatar Aug 30 '23 15:08 pgarm

I just want to share that this is also impacting me, and is another case of the Graph SDK's lack of "fit and finish." I will attempt to use the workaround provided here, thank you, or just use Invoke-MgGraphRequest. Thanks

jreinhardtproarch avatar Nov 14 '23 14:11 jreinhardtproarch

any progress on this issue?

Jakke2440 avatar Mar 20 '24 08:03 Jakke2440

Hey folks, just adding my 2c - been talking over this with @SteveMutungi254 since May and then it got kinda forgotten for a while, as I mistakenly popped the bug in ADO and not here :) Got a bit of flak from customers on this as they were building automation around the delta functionality. Given them this sample as a workaround, but certainly seems an overlooked capability ;)

@CarolKigoonya

How do you get the removed users with this sample? In my case it returns 380 users. The actual membership is 376 with 4 removed (1 object was deleted)

Using Get-MgGroupDelta objects that have been removed have an @removed key @odata.type id @removed

I don't see that when using the workaround sample. When using Invoke-MgGraphRequest and setting OutputType to PSObject that key is not included.

$groupDelta.value.'members@delta' | Get-member | select name

Name Equals GetHashCode GetType ToString @odata.type id

timmgreen avatar Apr 26 '24 20:04 timmgreen

any ETA on this issue?

MartinM85 avatar Jul 08 '24 07:07 MartinM85