microsoft / microsoft/powerbi-powershell

Error Acquiring Token / Unable to load System.Diagnostics.DiagnosticSource

Open
#433 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
413
Forks
134
Avg merge
33m
Merged PRs (30d)
1

Description

Good afternoon,

We've been receiving the following error when running Connect-PowerBIServiceAccount -ServicePrincipal after updating to version 1.3.80:

Connect-PowerBIServiceAccount : One or more errors occurred. (Error Acquiring Token:
System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Could not find or load a specific file. (0x80131621)
File name: 'System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
 ---> System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
   at System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name)
   at System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(RuntimeAssembly assembly, String assemblyFullName)
   at Microsoft.Identity.Client.Platforms.Features.OpenTelemetry.OtelInstrumentation..ctor()
   at Microsoft.Identity.Client.PlatformsCommon.Shared.AbstractPlatformProxy.InternalGetOtelInstrumentation()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
   at System.Lazy`1.CreateValue()
   at Microsoft.Identity.Client.PlatformsCommon.Shared.AbstractPlatformProxy.get_OtelInstrumentation()
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.LogFailureTelemetryToOtel(String errorCodeToLog, ApiIds apiId, CacheRefreshReason cacheRefreshReason)
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
   at Microsoft.Identity.Client.ApiConfig.Executors.ConfidentialClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenForClientParameters clientParameters, CancellationToken cancellationToken)
   at Microsoft.PowerBI.Common.Authentication.ServicePrincipalAuthenticationFactory.Authenticate(String clientId, SecureString clientSecret, IPowerBIEnvironment environment, IPowerBILogger logger, IPowerBISettings settings))

Output of Get-Module -ListAvailable MicrosoftPowerBIMgmt*:

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   1.3.80                MicrosoftPowerBIMgmt                Desk      
Binary     1.3.80                MicrosoftPowerBIMgmt.Admin          Desk      {Add-PowerBIEncryptionKey, Get-PowerBIE…
Binary     1.3.80                MicrosoftPowerBIMgmt.Capacities     Desk      Get-PowerBICapacity
Binary     1.3.80                MicrosoftPowerBIMgmt.Data           Desk      {Add-PowerBIDataset, Set-PowerBITable, …
Binary     1.3.80                MicrosoftPowerBIMgmt.Profile        Desk      {Connect-PowerBIServiceAccount, Disconn…
Binary     1.3.80                MicrosoftPowerBIMgmt.Reports        Desk      {Get-PowerBIReport, New-PowerBIReport, …
Binary     1.3.80                MicrosoftPowerBIMgmt.Workspaces     Desk      {Get-PowerBIWorkspace, Get-PowerBIWorks…

Full command:

$password = ConvertTo-SecureString $clientSecret -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential ("$clientId", $password)
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credentials -Tenant "$tenantId"

I have verified that this works with version 1.2.1111 of the module.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing Connect-PowerBIServiceAccount -ServicePrincipal with MicrosoftPowerBIMgmt 1.3.80 and compare it with 1.2.1111. Inspect the MicrosoftPowerBIMgmt.Profile module and its dependency packaging around System.Diagnostics.DiagnosticSource and the Microsoft.Identity.Client stack trace. Done means service-principal authentication works on 1.3.80 without the assembly-load error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
authentication, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.