Skip to content

Migrate dnceng insertion token from PAT to WIF (DefaultAzureCredential)#83058

Open
missymessa wants to merge 1 commit intodotnet:mainfrom
missymessa:missymessa-10097-wif
Open

Migrate dnceng insertion token from PAT to WIF (DefaultAzureCredential)#83058
missymessa wants to merge 1 commit intodotnet:mainfrom
missymessa:missymessa-10097-wif

Conversation

@missymessa
Copy link
Copy Markdown
Member

@missymessa missymessa commented Apr 3, 2026

Summary

Replaces the dn-bot-dnceng-build-e-code-full-release-e-packaging-r PAT with WIF-based authentication via AzureCLI@2 and DefaultAzureCredential for the VS insertion step.

Background

As part of the dnceng PAT-to-Entra migration (AB#10097), we're eliminating PAT usage in favor of modern authentication. The roslyn-tools create-insertion CLI already supports bearer tokens via its DefaultAzureCredential fallback — when --dnceng-azdo-token is unset, the tool uses DefaultAzureCredential().GetToken() for the AzDO resource and creates a VssOAuthAccessTokenCredential.

Changes

eng/pipelines/insert.yml:

  • Replaced dncEngAzdoToken parameter with dncEngAzureSubscription (service connection name)
  • Converted the create-insertion step from inline powershell: to task: AzureCLI@2
  • Passes --dnceng-azdo-token unset so DefaultAzureCredential (specifically AzureCliCredential) acquires the token automatically
  • The devdiv token continues to be passed as a PAT (separate migration)

azure-pipelines-official.yml & azure-pipelines-pr-validation.yml:

  • Pass dncEngAzureSubscription: 'Darc: Maestro Production' instead of the PAT variable

How it works

Inside AzureCLI@2, the Azure CLI is pre-authenticated via WIF. When roslyn-tools sees --dnceng-azdo-token unset, it falls back to DefaultAzureCredential which picks up AzureCliCredential and calls az account get-access-token --resource 499b84ac-... to get a bearer token for AzDO.

Uses the existing Darc: Maestro Production service connection, already authorized for this pipeline. The SP may need dnceng org permissions for build/code access if not already enrolled.

Testing

This should be validated via a PR validation run that triggers the insert stage. The create-insertion tool will log whether it's using PAT or OAuth authentication.

Microsoft Reviewers: Open in CodeFlow

@missymessa missymessa requested a review from a team as a code owner April 3, 2026 21:38
@dotnet-policy-service dotnet-policy-service bot added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Apr 3, 2026
Replace the dn-bot-dnceng-build-e-code-full-release-e-packaging-r PAT with
WIF-based authentication via AzureCLI@2 and DefaultAzureCredential for the
VS insertion step.

The roslyn-tools create-insertion CLI already supports bearer tokens via
DefaultAzureCredential fallback: when --dnceng-azdo-token is 'unset', the
tool calls DefaultAzureCredential().GetToken() for the AzDO resource and
uses VssOAuthAccessTokenCredential.

Changes:
- eng/pipelines/insert.yml: Replace dncEngAzdoToken parameter with
  dncEngAzureSubscription; wrap create-insertion in AzureCLI@2 so
  AzureCliCredential provides the token automatically
- azure-pipelines-official.yml: Pass service connection instead of PAT
- azure-pipelines-pr-validation.yml: Same

Uses the existing 'Darc: Maestro Production' service connection, which is
already authorized for this pipeline.

Addresses: AB#10097
@missymessa missymessa force-pushed the missymessa-10097-wif branch from 9e07a9a to 8b1b1c4 Compare April 3, 2026 22:12
@missymessa
Copy link
Copy Markdown
Member Author

Hey Roslyn team, let me know how I can best test this change to make sure the new Service Connection works. Thanks!

@jjonescz
Copy link
Copy Markdown
Member

jjonescz commented Apr 7, 2026

/pr-val

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

This PR is from an external author. You must specify a commit hash to trigger this workflow. Please use the format /dart <commit-hash> or /pr-val <commit-hash>.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Failed to trigger the pipeline. Please check the workflow logs for details.

@jjonescz
Copy link
Copy Markdown
Member

jjonescz commented Apr 7, 2026

/pr-val 8b1b1c4

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

View PR Validation Run triggered by @jjonescz

Parameters
  • Validation Type: pr-val
  • Pipeline ID: 8972
  • Pipeline Version: main
  • PR Number: 83058
  • Commit SHA: 8b1b1c457009ef3f606630215754bf226c2a19cd
  • Source Branch: missymessa-10097-wif
  • Target Branch: main
  • Build ID: 13763478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Infrastructure Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants