Skip to content

Commit f0e31f4

Browse files
authored
Merge pull request #9886 from mariaghiondea/patch-2
Enhance publishing guide with Entra ID authentication
2 parents cbf89af + 8c70b82 commit f0e31f4

1 file changed

Lines changed: 93 additions & 1 deletion

File tree

api/working-with-extensions/publishing-extension.md

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,99 @@ The publishing tool checks the following constraints:
6161

6262
Visual Studio Code uses [Azure DevOps](https://azure.microsoft.com/services/devops/) for its Marketplace services. This means that authentication, hosting, and management of extensions are provided through Azure DevOps.
6363

64-
`vsce` can only publish extensions using [Personal Access Tokens](https://learn.microsoft.com/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate). You need to create at least one in order to publish an extension.
64+
### Secure automated publishing to Visual Studio Marketplace
65+
66+
Follow these steps to improve security and align with Microsoft best practices!
67+
We strongly recommend that extension publishing use [Microsoft Entra ID–based authentication](https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/entra?view=azure-devops) with **workload identity federation and managed identities**, eliminating long-lived secrets such as Personal Access Tokens (PATs) and enabling secure, automated publishing pipelines.
68+
69+
This approach strengthens the overall security posture by removing reliance on stored credentials, simplifies operations through native integration with Azure Pipelines and Entra ID, scales effectively across environments, and aligns with modern identity and access management standards required for enterprise compliance. For more information, see [Reduce PAT usage](https://devblogs.microsoft.com/devops/reducing-pat-usage-across-azure-devops/).
70+
71+
1. Create a Service Connection (Azure DevOps)
72+
73+
- Navigate to **Project Settings → Service Connections**
74+
- Create a new **Azure Resource Manager** connection
75+
- Select **Workload Identity Federation (manual)**
76+
- Save the connection in draft mode to collect required values later
77+
78+
2. Create a Managed Identity (Azure)
79+
80+
- Create a **user-assigned managed identity** in Azure
81+
- Assign the **Reader** role
82+
- Record the following values: **Client ID**, **Tenant ID**, **Subscription** details
83+
84+
3. Configure Federated Credentials
85+
86+
Establish link between Azure DevOps and Azure:
87+
88+
- Add a federated credential to the managed identity
89+
- Exchange required values between systems:
90+
* From Azure DevOps → Azure: **issuer and subject**
91+
* From Azure → Azure DevOps: **client ID, tenant ID, subscription**
92+
- In Azure DevOps, select **Verify and save**
93+
94+
4. Grant Pipeline Access
95+
96+
- Open the service connection
97+
- Grant access to the pipelines responsible for publishing
98+
99+
5. Retrieve Managed Identity Resource ID (one-time)
100+
101+
- Run an Azure CLI task to retrieve the identity information:
102+
```yaml
103+
steps:
104+
- task: AzureCLI@2
105+
displayName: 'Get identity details'
106+
inputs:
107+
azureSubscription: <ServiceConnectionName>
108+
scriptType: pscore
109+
scriptLocation: inlineScript
110+
inlineScript: |
111+
az rest -u https://app.vssps.visualstudio.com/_apis/profile/profiles/me --resource 499b84ac-1321-427f-aa17-267ca6975798
112+
```
113+
- From the output JSON, capture the managed identity resource ID (the `id` field).
114+
115+
6. Authorize the Identity in Visual Studio Marketplace
116+
117+
- Add the managed identity (using its resource ID) as a member of your publisher.
118+
- Assign the **Contributor** role
119+
120+
7. Configure the CI/CD Pipeline
121+
122+
- Set up your Azure Pipelines CI/CD workflow
123+
- Replace PAT-based authentication with the identity-based approach
124+
125+
8. Publish Using Managed Identity
126+
127+
- In your pipeline, generate a Microsoft Entra ID (AAD) access token via Azure CLI.
128+
- Use the token with your publishing commands (for example: `vsce publish --azure-credential`).
129+
130+
Sample YAML tasks. Replace <ExtensionDirectory> with the extension directory path.
131+
132+
```yaml
133+
# Install VS Code Extension Manager (vsce >= v2.26.1 needed) and dependencies
134+
- script: |
135+
cd <ExtensionDirectory>
136+
npm install -g @vscode/vsce
137+
npm install
138+
displayName: "Install vsce and dependencies"
139+
140+
# Publish
141+
- task: AzureCLI@2
142+
displayName: 'Publish using managed identity'
143+
inputs:
144+
azureSubscription: <ServiceConnectionName>
145+
scriptType: pscore
146+
scriptLocation: inlineScript
147+
inlineScript: |
148+
cd <ExtensionDirectory>
149+
vsce publish --azure-credential
150+
```
151+
152+
***
153+
`vsce` can also publish extensions using [Personal Access Tokens](https://learn.microsoft.com/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate).
154+
155+
> [!IMPORTANT]
156+
> Due to security concerns, consider using the more secure Microsoft Entra tokens over higher-risk personal access tokens.
65157

66158
### Get a Personal Access Token
67159

0 commit comments

Comments
 (0)