Skip to content

Improve token handling and cleanup in docker.md for Linux/Bash script#14365

Open
ianwallen wants to merge 2 commits into
MicrosoftDocs:mainfrom
ianwallen:patch-2
Open

Improve token handling and cleanup in docker.md for Linux/Bash script#14365
ianwallen wants to merge 2 commits into
MicrosoftDocs:mainfrom
ianwallen:patch-2

Conversation

@ianwallen
Copy link
Copy Markdown

@ianwallen ianwallen commented Apr 4, 2026

Refactor token loading and cleanup functions in docker Linux/Bash script to fix some bugs.

Fixes issue with this error during cleanup
WRITE ERROR: VS30063: You are not authorized to access https://dev.azure.com.
This error happens because at agent start time, it will fetch a token using the client id/secret which works during startup. However the agent may wait for several hours/days before getting triggered and due to this long duration, the token that was fetched at startup is no longer valid during the cleanup therefore a new token should be fetched during cleanup.

Also fixed issue with hard code AZP_TOKEN_FILE location being a hard coded path /azp/.token which may not exists. Changed it to use the same location as the script location.

@ianwallen
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@prmerger-automator
Copy link
Copy Markdown
Contributor

@ianwallen : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

@ttorble
Copy link
Copy Markdown
Contributor

ttorble commented Apr 6, 2026

@steved0x

Can you review the proposed changes?

IMPORTANT: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the Azure Pipelines agent Docker start.sh example in docker.md to improve token handling, especially for service-principal-based tokens that can expire between agent startup and cleanup.

Changes:

  • Introduces load_azp_token() to centralize token acquisition and token-file writing.
  • Updates cleanup() to refresh the token before removing agent configuration when using service principal credentials.
  • Changes the default AZP_TOKEN_FILE location to be relative to the script and expands VSO_AGENT_IGNORE.

Comment thread docs/pipelines/agents/docker.md
Comment thread docs/pipelines/agents/docker.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread docs/pipelines/agents/docker.md
Comment thread docs/pipelines/agents/docker.md Outdated
Comment thread docs/pipelines/agents/docker.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread docs/pipelines/agents/docker.md Outdated
Comment thread docs/pipelines/agents/docker.md Outdated
Comment thread docs/pipelines/agents/docker.md Outdated
Comment thread docs/pipelines/agents/docker.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread docs/pipelines/agents/docker.md Outdated
Comment thread docs/pipelines/agents/docker.md
Comment thread docs/pipelines/agents/docker.md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread docs/pipelines/agents/docker.md Outdated
Comment thread docs/pipelines/agents/docker.md
Comment thread docs/pipelines/agents/docker.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread docs/pipelines/agents/docker.md Outdated
Comment thread docs/pipelines/agents/docker.md Outdated
Comment thread docs/pipelines/agents/docker.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread docs/pipelines/agents/docker.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread docs/pipelines/agents/docker.md
Comment thread docs/pipelines/agents/docker.md
@ianwallen ianwallen changed the title Improve token handling and cleanup in docker.md Improve token handling and cleanup in docker.md for Linux/Bash script May 5, 2026
Refactor token loading and cleanup functions in docker for Linux/Bash script.

Fixes issue with this error during cleanup
    WRITE ERROR: VS30063: You are not authorized to access https://dev.azure.com.

Also fixed issue with hard code AZP_TOKEN_FILE location being a hard coded path /azp/.token which may not exists.  Changed it to use the same location as the script location.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@v-dirichards
Copy link
Copy Markdown
Contributor

@steved0x

Can you review this old PR and determine whether it needs to be closed or merged?

@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator
Copy link
Copy Markdown
Contributor

@ianwallen : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants