microsoftgraph / microsoftgraph/msgraph-sdk-powershell
Support different contexts per runspace/thread
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 898
- Forks
- 230
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 31
Description
We have a service which manages cost and security governance across several thousand tenants. This service runs in Azure Functions, which scales out by creating additional Powershell runspaces. The challenge is that the msgraph cmdlets only have a single per-process context which changes when calling Connect-MgGraph.
This causes the following behavior:
- Runspace 1 calls Connect-MgGraph -TenantId <Tenant 1> and starts running other graph commands.
- Runspace 2 starts and calls onnect-MgGraph -TenantId <Tenant 2>.
- Runspace 1 incorrectly executes its commands against Tenant 2.
Our service also manages Azure subscriptions using the Az cmdlets. Az cmdlets solves the multiple runspace issue by providing the -DefaultProfile parameter on all commands. This allows each runspace to execute independently against different tenants and subscriptions. The pattern looks like:
$ctx = Connect-AzAccount -Tenant $TenantId -Subscription $SubId
Get-AzVM -DefaultProfile $ctx
Ask:
Provide a common -DefaultProfile type of parameter for all msgraph cmdlets which allows for a saved context to be utilized.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing Connect-MgGraph and how the Microsoft Graph cmdlets store and retrieve their process-wide context; the issue does not name specific files or tests. Define how a shared DefaultProfile-type context would be created and passed so separate runspaces can target different tenants independently, then verify the pattern across the cmdlets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100