> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-cloud/expand-your-projects-capabilities/cloud-extensions/private-nuget-feed.md).

# Private NuGet Feed on Umbraco Cloud

A private NuGet feed is a package repository that is only accessible to a specific group of users, rather than being publicly available.

Private feeds are often used to host internal libraries or proprietary software within an organization.

NuGet is a package manager for the Microsoft development platform, including `.NET`. It gives you the ability to add, remove, and update libraries and tools in Visual Studio projects.

In this tutorial, we'll be covering how to set up a private NuGet feed with Umbraco Cloud.

## Prerequisite

To follow along with this tutorial, you'll need the following tools:

1. [Visual Studio](https://visualstudio.microsoft.com/downloads/)
2. A NuGet server such as [MyGet](https://www.myget.org/)
3. An Umbraco Cloud project on a standard plan or higher

## Step 1: Create a NuGet package

The first part of this tutorial is to create and publish a NuGet package using Visual Studio.

To create and publish a NuGet package with Visual Studio, you will need to follow the [Microsoft Documentation](https://learn.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-visual-studio?tabs=netcore-cli).

## Step 2: Create your own MyGet feed

Once the first step is completed, we need to create our own MyGet feed.

To create the MyGet feed, follow the [MyGet documentation.](https://docs.myget.org/docs/walkthrough/getting-started-with-nuget)

When you create the MyGet feed, it needs to be created as private.

## Step 3: Publish your NuGet package

We will publish our NuGet package to your MyGet feed in the third step.

There are two ways to do so:

* Go directly to your MyGet feed and upload the NuGet package.
* Follow the [Microsoft Documentation](https://learn.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-visual-studio?tabs=netcore-cli#publish-with-the-dotnet-cli-or%EF%BF%BDnugetexe-cli).

## Step 4: Add private MyGet feed on Umbraco Cloud

In the last step, we will add the private feed to our Umbraco cloud project.

To add the private feed to your Cloud project, follow the steps below:

1. Access the cloud [Secrets Management](https://docs.umbraco.com/umbraco-cloud/set-up/project-settings/secrets-management).
2. Add your MyGet credentials as a Shared Secret.
3. Clone down your Umbraco Cloud project.
4. Open the project locally and build/spin up the site.
5. Go to your `NuGet.Config` file in the root of your project.
6. Add the below configuration to the file:

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
	<add key="MyGet" value="https://www.myget.org/F/YourMyGetFeed/api/v3/index.json" />
  </packageSources>

	<packageSourceCredentials>
		<MyGet>
			<add key="Username" value="YourUsername" />
			<add key="ClearTextPassword" value="%MYGET_PASSWORD%" />
		</MyGet>
	</packageSourceCredentials>

  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  
</configuration>
```

In the above code example, you can see that we are using the Key: "`MYGET_PASSWORD`" that we created in the previous step. We did that by using the Cloud Secrets Management feature on Umbraco Cloud.

7. Push the changes to your Umbraco Cloud project.

Congratulations, you've successfully set up a private NuGet feed with Umbraco Cloud using the cloud secrets management feature!

You can now use this feed to host and manage your own internal libraries or proprietary software. If you want to learn more about NuGet and how to use it, check out the official [NuGet documentation](https://learn.microsoft.com/en-us/nuget/).

## Hints to use Azure DevOps private feeds

For Azure DevOps feeds, it is recommended to use Personal Access Tokens (PAT). The PAT must have at a minimum the "Packaging (Read)" permission to consume packages from the feed.

{% hint style="info" %}
PAT-tokens in Azure DevOps have an expiration date. Make sure to update your secret when you rotate your tokens.
{% endhint %}

Below is an example `NuGet.Config` configured for an Azure DevOps private feed:

{% code title="NuGet.Config" %}

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="Team_Internal" value="https://pkgs.dev.azure.com/AwesomeOrganization/_packaging/Team_Internal/nuget/v3/index.json" />
  </packageSources>

  <packageSourceCredentials>
    <Team_Internal>
      <add key="Username" value="placeholder" />
      <add key="ClearTextPassword" value="%TEAM_INTERNAL_PAT_TOKEN%" />
    </Team_Internal>
  </packageSourceCredentials>

  <packageSourceMapping>
    <packageSource key="nuget.org">
      <package pattern="*" />
    </packageSource>
    <packageSource key="Team_Internal" >
      <package pattern="AwesomeOrganizationPackagePrefix*" />
    </packageSource>
  </packageSourceMapping>
  
</configuration>
```

{% endcode %}

### Troubleshooting

If you experience any errors with restores on Umbraco Cloud and private NuGet feeds, there are a couple of things to consider:

* Make sure passwords, API keys, or PAT-tokens are correct.
* Secret values may have changed, but have not been updated in Secrets Management.
* In MyGet, the username is not an email address but the account username associated with the API key.
* PAT-tokens in Azure DevOps can expire - check if the value needs to be rotated. Remember to update the secret in the Cloud Portal.
* PAT-tokens in Azure DevOps need to have the right kind of permission. Make sure it has the 'Read' permission on 'Packaging'.

### Test the connection to a private feed locally

It is a good idea to validate the connection to a feed locally before using it on Cloud.

It is usually easier to troubleshoot if there are connection issues or problems with credentials.

You need to update the `NuGet.Config` file by replacing any placeholder values with valid credentials.

{% hint style="info" %}
Do not commit the `NuGet.Config` file with credentials in plain text.
{% endhint %}

Run the command: `dotnet restore --force --no-cache -v detailed`.

If there are any errors, start by going through the troubleshooting section above.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.umbraco.com/umbraco-cloud/expand-your-projects-capabilities/cloud-extensions/private-nuget-feed.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
