- Published on
Nuget, NPM and MVN packages in ACR
Introduction
In recent developments, Azure Container Registry (ACR) has expanded its capabilities beyond just deploying container images and Helm charts. It now supports the deployment of various application packages, including NuGet packages, Maven packages, npm packages, and more. This versatility is made possible by adhering to the OCI (Open Container Initiative) standards and utilizing the ORAS project.
What is ORAS?
ORAS stands for OCI Registry and Artifact Storage. It is an OCI registry client, essentially a command-line tool that helps manage an array of content such as artifacts, images, and packages. ORAS is capable of interoperating with multiple container registries, including ACR, Google Artifact Registry, JFrog, Harbor, Amazon Elastic Container Registry, GitHub Packages, Docker Hub, GitLab Container Registry, and many others. As an open-source project, ORAS is maintained by the Cloud Native Computing Foundation (CNCF).
Getting Started with ORAS
Before you can utilize ORAS to push and pull packages from ACR, ensure it is installed on your local machine. Installation varies by operating system; for instance, Windows users can install ORAS via NuGet.
Here's a quick rundown of the steps to use ORAS for package management with ACR:
- Create a Resource Group.
- Set up an ACR instance.
- Log in to the ACR using Azure CLI.
- Fetch an access token for authentication.
- Use ORAS commands to push and pull application packages, including NuGet packages.
Demonstration: Using ORAS to Push and Pull NuGet Packages
Step 1: Create an Azure Resource Group and ACR
Using the Azure CLI, you can create a resource group and an ACR using the following command:
az group create --name <ResourceGroupName> --location <Location>
az acr create --resource-group <ResourceGroupName> --name <RegistryName> --sku Basic
Step 2: Log into ACR
Next, log into the ACR:
az acr login --name <RegistryName> --expose-token
This will generate an access token. Store this token in an environment variable, which will be used for authentication with ORAS.
Step 3: Authenticate with ORAS
Use the access token and default username to log in to the ACR through ORAS:
export ORAS_CLIENT_TOKEN=<access_token>
oras login <RegistryName> --username <default_username> --password $ORAS_CLIENT_TOKEN
Upon successful login, you should see the message "login succeeded".
Step 4: Push a NuGet Package to ACR
For demonstration, let's push a sample NuGet package, such as "Newtonsoft.Json" version 13.0.3. Use the following command to push the package:
oras push <RegistryName>/<RepositoryName>:<Tag> <PathToPackage>
If successful, you should see a confirmation message.
Step 5: Verify the Package Hosted in ACR
To verify that the package has been uploaded, navigate to the ACR in the Azure portal:
- Go to the Resource Group.
- Click on the ACR instance.
- Navigate to "Repositories" to see the newly hosted package.
Step 6: Pull the NuGet Package
To pull the package back into your local environment, run:
oras pull <RegistryName>/<RepositoryName>:<Tag> --output <LocalFolder>
Upon successful execution, the package will be available in your specified local folder.
Step 7: Pushing Other Artifacts
You can also push other types of files, such as markdown files, using a similar ORAS push command. This demonstrates how flexible ORAS can be in managing various artifacts.
Conclusion
The integration of ORAS with Azure Container Registry allows you to push and pull multiple types of application packages efficiently. By leveraging OCI standards, developers can take advantage of streamlined workflows for managing artifacts.
Keywords
- Azure Container Registry (ACR)
- ORAS
- OCI Standard
- Nuget Packages
- Maven Packages
- NPM Packages
- Command Line Tool
- Artifact Management
FAQ
Q1: What is Azure Container Registry (ACR)?
A1: ACR is a managed Docker container registry service in Azure that allows you to store and manage container images and artifacts.
Q2: What does ORAS do?
A2: ORAS is a command-line tool that allows you to push and pull not only container images but also other package types, such as NuGet and Maven packages, to and from OCI-compliant registries.
Q3: How do I install ORAS?
A3: ORAS can be installed through package managers like NuGet on Windows or by using the appropriate installation instructions for Linux and macOS.
Q4: Can I push other file types using ORAS?
A4: Yes, ORAS allows you to push and pull a variety of file types, including markdown files, in addition to standard application packages.
Q5: Is ORAS an open-source project?
A5: Yes, ORAS is maintained as an open-source project under the Cloud Native Computing Foundation (CNCF).