You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api/working-with-extensions/publishing-extension.md
+93-1Lines changed: 93 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,99 @@ The publishing tool checks the following constraints:
61
61
62
62
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.
63
63
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
- 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.
0 commit comments