githubEdit

Azure Storage

The DecSm.Atom.Module.AzureStorage module provides robust capabilities for managing build artifacts using Azure Blob Storage. This integration allows your DecSm.Atom build processes to securely store and retrieve build outputs, ensuring persistence and accessibility across different build runs and environments.

Features

  • Artifact Storage: Upload build artifacts to a specified Azure Blob Storage container.

  • Artifact Retrieval: Download previously stored artifacts from Azure Blob Storage.

  • Cleanup Functionality: Remove artifacts associated with specific build runs from storage.

  • Parameter-driven Configuration: Configure Azure Storage connection details and container names using build parameters.

  • Build ID and Slice Integration: Organizes artifacts within the storage container based on build ID and optional build slices for easy management and retrieval.

Getting Started

To use the Azure Storage module, you need to implement the IAzureArtifactStorage interface in your build definition. This interface provides the necessary parameters for connecting to your Azure Storage account and container.

Prerequisites

Before you begin, ensure you have:

  1. An Azure Storage account.

  2. A Blob Storage container within that account where artifacts will be stored.

  3. The connection string for your Azure Storage account.

Implementation

Add the IAzureArtifactStorage interface to your Build.cs file:

Configuration Parameters

The IAzureArtifactStorage interface exposes the following parameters, which you can set via command-line arguments, environment variables, or appsettings.json:

  • azurestorage-artifact-connectionstring: The connection string for your Azure Storage account. This is a SecretDefinition and should be handled securely.

  • azurestorage-artifact-container: The name of the Azure Blob Storage container where artifacts will be stored (e.g., build-artifacts).

Example appsettings.json Configuration

Note: The azurestorage-artifact-connectionstring is a sensitive credential and should always be stored securely, preferably in the Secrets section of appsettings.json or as a secret environment variable in your CI/CD system.

Command-Line Example

Storing Artifacts

To store artifacts, you can use the StoreArtifacts method provided by the IArtifactProvider interface. The AzureBlobArtifactProvider is automatically registered when you implement IAzureArtifactStorage.

Artifacts are expected to be located in the AtomPublishDirectory (typically _output/publish relative to your repository root). Each artifact name you provide to StoreArtifacts should correspond to a subdirectory within this publish directory.

Artifacts are stored in a hierarchical structure within the container: <buildName>/<buildIdGroup>/<buildId>/<artifactName>/<buildSlice>/<filePath>

For example: MyProject/2023/20231027-123456/MyApp/main/app.zip

Retrieving Artifacts

To retrieve artifacts, use the RetrieveArtifacts method. This will download the specified artifacts into your AtomArtifactsDirectory (typically _output/artifacts).

Cleaning Up Artifacts

The Cleanup method allows you to remove artifacts associated with one or more build IDs.

Getting Stored Run Identifiers

You can query for existing build IDs that have stored artifacts using GetStoredRunIdentifiers. This can be useful for managing or reporting on available artifacts.

Last updated

Was this helpful?