azurebs/

directory
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: Apache-2.0

README

Azure Blob Storage Client

Azure Blob Storage client implementation for the unified storage-cli tool. This module provides Azure Blob Storage operations through the main storage-cli binary.

Note: This is not a standalone CLI. Use the main storage-cli binary with -s azurebs flag to access Azure Blob Storage functionality.

For general usage and build instructions, see the main README.

Azure-Specific Configuration

The Azure client requires a JSON configuration file with the following structure:

{
  "account_name":           "<string> (required)",
  "account_key":            "<string> (required)",
  "container_name":         "<string> (required)",
  "environment":            "<string> (optional, default: 'AzureCloud')"
}

Usage examples:

# Upload a blob
storage-cli -s azurebs -c azure-config.json put local-file.txt remote-blob

# Fetch a blob (destination file will be overwritten if exists)
storage-cli -s azurebs -c azure-config.json get remote-blob local-file.txt

# Delete a blob
storage-cli -s azurebs -c azure-config.json delete remote-blob

# Check if blob exists
storage-cli -s azurebs -c azure-config.json exists remote-blob

# Generate a signed URL (e.g., GET for 3600 seconds)
storage-cli -s azurebs -c azure-config.json sign remote-blob get 3600s
Using Signed URLs with curl
# Uploading a blob:
curl -X PUT -H "x-ms-blob-type: blockblob" -F 'fileX=<path/to/file>' <signed-url>

# Downloading a blob:
curl -X GET <signed-url>

Testing

Unit Tests

Run from the repository root directory:

ginkgo --skip-package=integration --randomize-all --cover -v -r ./azurebs/...

Or using go test:

go test $(go list ./azurebs/... | grep -v integration)
Integration Tests
  • To run the integration tests with your existing container

    1. Export the following variables into your environment.

      export ACCOUNT_NAME=<your Azure accounnt name>
      export ACCOUNT_KEY=<your Azure account key>
      export CONTAINER_NAME=<the target container name>
      
    2. Navigate to project's root folder and run the command below:

      go test ./azurebs/integration/...
      
  • To run it from scratch; create a new container, run tests, delete the container

    1. Create a storage account in your azure subscription.
    2. Get account name and access key from you storage account.
    3. Export account name with command export azure_storage_account=<account name>.
    4. Export access key with command export azure_storage_key=<access key>.
    5. Navigate to project's root folder.
    6. Run environment setup script to create container ./.github/scripts/azurebs/setup.sh.
    7. Run tests ./.github/scripts/azurebs/run-int.sh.
    8. Run environment teardown script to delete test resources ./.github/scripts/azurebs/teardown.sh.

Directories

Path Synopsis
clientfakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL