Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

Azure Artifacts: Private Package Feeds (npm, NuGet, Maven)

By Kokil Thapa | Last reviewed: August 2026

Azure Artifacts private package feeds provide a centralized, secure registry for sharing internal libraries across npm, NuGet, and Maven ecosystems within your organization. When building reusable components for client projects or managing proprietary dependencies, relying on public registries introduces security risks and versioning chaos. This guide covers the practical configuration, authentication patterns, and CI/CD integration required to run Azure Artifacts: Private Package Feeds (npm, NuGet, Maven) effectively in production environments.

How do you configure Azure Artifacts private package feeds for npm?

Setting up npm feeds in Azure Artifacts requires careful attention to authentication and scope configuration. Unlike public npm, private feeds demand explicit credential management that differs between local development and automated build systems. For teams transitioning from ad-hoc Git-based dependency management, this shift enables proper versioning and audit trails—critical when maintaining multiple client projects like those described in Laravel development workflows.

DeveloperLocal MachineCI PipelineAzure DevOpsPrivate FeedInternal PackagesUpstreamnpmjs.comAuthentication Flow1. Generate PAT ( Packaging Read/Write )2. Base64 encode: echo -n ":PAT" | base643. Add to .npmrc: //pkgs.dev.azure.com/.../:_authToken=BASE644. Set registry: registry=https://pkgs.dev.azure.com/.../npm/registry/
Azure Artifacts npm feed architecture with authentication flow for developers and CI pipelines

Configuring .npmrc for private feeds

The .npmrc file is where feed authentication lives. A common mistake is committing credentials to version control or using user-level configs that break in CI. Always use project-scoped .npmrc files with environment variable substitution:

# .npmrc (project root)
registry=https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feed}/npm/registry/
always-auth=true

# Authentication token injected via environment variable
//pkgs.dev.azure.com/{org}/{project}/_packaging/{feed}/npm/:_authToken=${NPM_TOKEN}

# Upstream caching ensures public packages resolve through your feed
@your-org:registry=https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feed}/npm/registry/

In CI pipelines, inject NPM_TOKEN as a secret variable. Locally, use npm login --registry=https://pkgs.dev.azure.com/... to generate temporary credentials without storing PATs in plain text. For monorepos using workspaces, place the .npmrc at the workspace root to ensure consistent resolution across all packages.

Publishing packages with proper scoping

Scoped packages (@your-org/package-name) prevent naming collisions and clearly signal internal origin. Before publishing, verify your package.json includes:

  • "name": "@your-org/component-library"
  • "publishConfig": { "registry": "https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feed}/npm/" }
  • "repository": { "type": "git", "url": "https://dev.azure.com/{org}/{project}/_git/{repo}" }

Run npm publish from the package directory. Azure Artifacts enforces immutable versions by default—once published, a version cannot be overwritten. This prevents supply chain attacks but requires disciplined version bumping. Use semantic versioning strictly; reserve prerelease tags (-beta.1) for testing before promoting to stable.

What are the key differences between NuGet and Maven feed setup in Azure Artifacts?

While npm relies on .npmrc, NuGet and Maven use platform-native configuration files with distinct authentication mechanisms. Understanding these differences prevents frustrating debugging sessions when onboarding new team members or integrating legacy systems.

AspectnpmNuGetMaven
Config File.npmrcnuget.config / NuGet.Configsettings.xml / pom.xml
Auth MethodBase64-encoded PAT in _authTokenCredential provider or API keyServer entry with username/PAT
Scope SupportYes (@scope/package)No (use naming conventions)GroupId acts as namespace
Upstream CachingAutomatic per-feedAutomatic per-feedAutomatic per-feed
CI Integrationnpm ci + env vardotnet restore + credential providermvn deploy + settings injection
Version ImmutabilityEnforcedEnforcedEnforced

NuGet configuration for .NET projects

NuGet feeds integrate directly with Visual Studio and the dotnet CLI. Create a nuget.config at your solution root:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="AzureArtifacts" value="https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feed}/nuget/v3/index.json" />
  </packageSources>
  <packageSourceCredentials>
    <AzureArtifacts>
      <add key="Username" value="azurartifacts" />
      <add key="ClearTextPassword" value="%NUGET_PAT%" />
    </AzureArtifacts>
  </packageSourceCredentials>
</configuration>

In Azure Pipelines, use the built-in NuGetAuthenticate task instead of manual credential injection—it automatically configures the credential provider and avoids exposing PATs. For local development, install the Azure Artifacts Credential Provider which handles interactive login and token refresh transparently.

Maven repository configuration for Java/JVM projects

Maven requires server definitions in settings.xml (usually ~/.m2/settings.xml) and repository declarations in pom.xml:

<!-- ~/.m2/settings.xml -->
<servers>
  <server>
    <id>azure-artifacts</id>
    <username>azurartifacts</username>
    <password>${env.MAVEN_PAT}</password>
  </server>
</servers>

<!-- pom.xml repositories section -->
<repositories>
  <repository>
    <id>azure-artifacts</id>
    <url>https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feed}/maven/v1</url>
  </repository>
</repositories>

<distributionManagement>
  <repository>
    <id>azure-artifacts</id>
    <url>https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feed}/maven/v1</url>
  </repository>
</distributionManagement>

The <id> must match exactly between settings.xml and pom.xml. In CI, pass MAVEN_PAT as an environment variable or use the MavenAuthenticate task. Note that Maven’s groupId serves as your namespace—use reverse domain notation (com.yourorg.project) to avoid conflicts with public artifacts.

npm.npmrc + _authTokenBase64(PAT)Scoped packages supportedNuGetnuget.config + CredProviderInteractive or API KeyNo native scopingMavensettings.xml + server idUsername + PAT env varGroupId as namespaceCommon Requirements Across All Ecosystems✓ Personal Access Token (Packaging Read/Write scope)✓ Feed URL includes organization and project name✓ Upstream sources enabled for public dependency caching✓ Version immutability enforced after first publish
Side-by-side comparison of authentication mechanisms for npm, NuGet, and Maven in Azure Artifacts private feeds

How do you integrate Azure Artifacts with CI/CD pipelines securely?

Hardcoding credentials in pipeline YAML is a security vulnerability waiting to happen. Azure DevOps provides dedicated tasks and service connections that handle authentication without exposing secrets. This pattern aligns with secure deployment practices discussed in CI/CD pipeline setup guides, where secret management is non-negotiable.

Azure Pipelines native authentication tasks

For each ecosystem, use the corresponding authenticate task before restore/publish operations:

# npm pipeline example
steps:
- task: NodeTool@0
  inputs:
    versionSpec: '22.x'

- task: npmAuthenticate@0
  inputs:
    workingFile: '$(Build.SourcesDirectory)/.npmrc'
    customEndpoint: 'AzureArtifactsFeedConnection'

- script: npm ci
  displayName: 'Install dependencies'

- script: npm publish
  displayName: 'Publish package'
  condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')

The npmAuthenticate task temporarily modifies the specified .npmrc with pipeline-generated credentials, then restores it after execution. This eliminates credential leakage in logs or artifacts. The same pattern applies to NuGetAuthenticate@1 and MavenAuthenticate@0.

Service connections for cross-project access

When multiple projects consume packages from a central feed, create a service connection under Project Settings → Service Connections → Azure Artifacts. This grants pipeline-level access without embedding PATs in YAML. Restrict permissions using feed-level security: give consuming projects "Contributor" access only if they need to publish, otherwise "Reader" suffices.

For GitHub Actions or external CI systems, use the actions/setup-node action with a scoped PAT stored as a repository secret. Generate tokens with minimal scope (Packaging Read for consumers, Read+Write for publishers) and rotate them quarterly. Never reuse PATs across different CI systems or team members.

Source RepoCode + .npmrcAuthenticateTask Injects CredRestore/BuildResolve DepsTest & ValidateQuality GatesPublishTo FeedSecurity Best Practices• Use pipeline tasks, never hardcode PATs in YAML• Scope tokens: Read-only for consumers, Write for publishers• Rotate credentials quarterly; audit usage logs monthly• Enable feed retention policies to auto-delete old versions• Restrict feed permissions per project/team identity
Secure CI/CD pipeline integration with Azure Artifacts showing authentication task placement and security checklist

What are the cost implications and retention strategies for Azure Artifacts?

Azure Artifacts charges per GB of stored data beyond the free tier (2 GB included). Without retention policies, feeds accumulate obsolete versions rapidly—especially in active monorepos. On a recent legal-tech portal project, we reduced storage costs by 60% within three months by implementing aggressive retention rules alongside the development workflow documented in legal tech solutions architecture.

Configuring retention policies

Navigate to Artifacts → Select Feed → Settings → Retention Policies. Configure two complementary rules:

  1. Version retention: Keep the latest N versions per package (e.g., 5 stable + 3 prerelease). Older versions are soft-deleted and recoverable for 30 days.
  2. Days-based retention: Delete versions older than X days regardless of count (e.g., 90 days for prereleases, 365 for stable). This catches abandoned packages that stop receiving updates.

Enable "Delete deleted versions permanently after 30 days" to prevent indefinite soft-delete accumulation. Monitor usage via the Artifacts analytics dashboard—identify packages with zero downloads in 90 days and archive or delete them. For large organizations, consider separate feeds per team or product line to isolate retention policies and simplify billing allocation.

Optimizing upstream source caching

Upstream sources cache public packages on first request, counting toward your storage quota. To minimize bloat:

  • Disable upstream caching for feeds containing only internal packages
  • Create dedicated "cache-only" feeds for public dependencies with shorter retention
  • Use npm ci instead of npm install to avoid unnecessary metadata requests
  • Audit cached packages quarterly; remove unused transitive dependencies

Remember that upstream caching improves build reliability during public registry outages—a worthwhile tradeoff for most production systems. Calculate the cost-benefit based on your team's build frequency and downtime tolerance rather than optimizing purely for storage savings.

Final recommendations for Azure Artifacts private package feeds

Azure Artifacts private package feeds deliver genuine value when configured with discipline: scoped authentication, automated CI integration, and proactive retention management. Start with a single feed per ecosystem, enforce semantic versioning from day one, and treat feed configuration as infrastructure code—not manual setup. For teams evaluating whether to adopt private feeds versus alternatives like GitHub Packages or self-hosted Verdaccio, prioritize integration depth with your existing Azure DevOps toolchain over marginal feature differences. If you're planning a migration or need help architecting a secure package management strategy for your development team, reach out to discuss your specific requirements.

Frequently Asked Questions

Azure Artifacts is a managed package hosting service within Azure DevOps supporting npm, NuGet, Maven, Python, and Universal feeds. It enables teams to share private libraries securely without exposing code publicly, integrating directly with CI/CD pipelines for automated dependency management and version control in enterprise environments.

Free tier includes 2 GiB storage and limited requests. Paid plans start at USD 30/month (~NPR 4,000) for 50 GiB. Costs scale with storage and request volume. For Nepal-based startups, evaluate if GitHub Packages or self-hosted Verdaccio offers better value before committing to Azure's per-user licensing model.

Generate a Personal Access Token with Packaging Read scope. Add your feed URL to .npmrc using the format registry=https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feed}/npm/registry/. Configure authentication via npm login or environment variables. Never commit tokens; use CI pipeline secrets or local .npmrc excluded from version control.

Yes for teams fully invested in Azure DevOps ecosystem. It lacks advanced features like virtual repositories, multi-format proxy caching, and granular LDAP integration that Nexus/Artifactory provide. If you need hybrid cloud/on-prem or non-Microsoft toolchains, dedicated repository managers remain superior despite higher operational overhead.

In feed settings, enable upstream sources and select npmjs.org, NuGet Gallery, or Maven Central. Azure caches public packages automatically, ensuring builds succeed during outages and reducing external dependencies. This also provides security scanning for cached packages. Configure retention policies to manage cache size and avoid unexpected storage costs.

Contributors need Feed Publisher role at minimum. Project Collection Administrators can manage feed creation and deletion. Use Azure AD groups for team-based access rather than individual accounts. For CI pipelines, grant Build Service account Contribute permission. Avoid giving Owner roles broadly; use least-privilege principle to prevent accidental feed deletion or policy changes.

Use azure-artifacts-migration-tool or write scripts to download tarballs and republish via npm publish --registry={azure-feed-url}. Preserve version history by publishing in chronological order. Update all consuming projects' .npmrc files simultaneously. Test thoroughly in staging before switching production builds. Expect 2-4 hours for medium-sized internal libraries with 50+ versions.

Yes, fully supports SemVer 2.0 including prerelease identifiers like alpha, beta, rc. Use views (alpha, beta, release) to promote packages through quality gates rather than relying solely on version tags. Views integrate with pipeline approvals, enabling controlled promotion from development to production feeds without republishing artifacts.

Verify PAT has Packaging Read scope and hasn't expired. Check .npmrc registry URL matches exact feed path including project name if scoped. Ensure no conflicting global .npmrc overrides project config. Regenerate token if compromised. For CI, confirm service connection uses correct credentials. Test with curl against feed endpoint to isolate auth versus network issues.

Yes. Create PAT with Packaging Read/Write scopes. Store as GitHub secret. Configure .npmrc or nuget.config in workflow using actions/setup-node or nuget/setup-nuget. Authenticate via environment variables. Note that GitHub-native Packages may be simpler if repo already lives there, avoiding cross-platform credential management and reducing vendor lock-in.

Configure feed-level retention in Azure DevOps settings. Set permanent delete after X days for unused versions. Exclude release-tagged packages from auto-deletion. Use views to protect promoted versions. Monitor storage via Usage tab weekly. For high-churn dev feeds, aggressive 30-day retention works; production feeds need 180+ days. Review quarterly to balance compliance and budget.

Integrated Microsoft Defender for DevOps scans npm, NuGet, and Maven packages for known CVEs during publish and periodically thereafter. Alerts appear in Azure Security Center. Blocked packages prevent installation based on severity thresholds. Enable automatic blocking for critical vulnerabilities. Combine with Dependabot or Snyk for broader ecosystem coverage, as Defender's database updates slower than specialized scanners.

Use single feed with scoped package names (@team/lib-name) rather than separate feeds per package. Configure .npmrc once at root. For complex orgs, create organization-scoped feed shared across projects. Avoid feed-per-repo pattern which creates maintenance burden. Use workspace protocols (pnpm/npm workspaces) locally; publish only built artifacts to feed. Document naming conventions to prevent collisions.

All feeds and packages are permanently deleted with no recovery option. Export critical packages beforehand using az artifacts universal download or npm pack. Maintain disaster recovery mirror in alternate system (GitHub Packages, Nexus). Include feed backup in offboarding checklist. For regulated industries, archive packages to immutable storage monthly. Treat Azure Artifacts as ephemeral unless contractual guarantees exist.

Use Universal for binaries, installers, ML models, or assets lacking native package manager support. They offer checksum verification and metadata but lack dependency resolution. For code libraries, always prefer npm/NuGet/Maven feeds for proper versioning and transitive dependency handling. Universal packages suit deployment artifacts or configuration bundles where traditional packaging adds unnecessary complexity.

Share this article

Quick Contact Options
Choose how you want to connect me: