Skip to content

[BUG]: Federated access is not working (or not getting expected env variables) #21082

@oasaleh

Description

@oasaleh

New issue checklist

Task name

AzurePowerShell

Task version

5

Issue Description

I have two tenants: A and B. Pipeline is in tenant B, while my SQL Server is in tenant A. I have a service connection that's known to work with other resources (a Blob storage account in Tenant A that's being access by other pipelines in the same pool using the same image.)

Image

I am trying to run the following in my pipeline.

variables:
  labConn: "Server=tcp:my-sql-server.database.windows.net;Initial Catalog=my-db-dev;Authentication=Active Directory Default;Encrypt=True;"

steps:
  - task: AzurePowerShell@5
    displayName: "Run EF bundles - DEV - Azure PowerShell"
    inputs:
      azureSubscription: "nameOfMyServiceConnection"
      pwsh: true
      azurePowerShellVersion: "LatestVersion"
      failOnStandardError: true
      scriptType: "InlineScript"
      workingDirectory: $(Pipeline.Workspace)/ci/drop/ef-bundles
      Inline: |
        ./lab-db.exe      --connection "$(labConn)"

I get the following error:

Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user '<token-identified principal>'. The server is not currently configured to accept this token.

I already gave the MI in Tenant A that's connected to the service connection access to the SQL DB.

When I dump env variables, I get the following:

AZURESUBSCRIPTION_CLIENT_ID=<MI's object ID in Tenant A>
AZURESUBSCRIPTION_SERVICE_CONNECTION_ID=<A GUID>
AZURESUBSCRIPTION_TENANT_ID=<Tenant A ID>

To my understanding, these are not the expected names for env variables.
Also, shouldn't there be a AZURE_FEDERATED_TOKEN_FILE as well?

Thanks!

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Microsoft Windows Server 2022

Relevant log output

Login failed for user '<token-identified principal>'. The server is not currently configured to accept this token.

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions