Skip to content

cloudfoundry/bosh-azure-storage-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

29d2703 · Mar 29, 2025
Sep 27, 2023
Aug 12, 2024
Aug 12, 2024
Aug 12, 2024
Jul 13, 2023
Mar 29, 2025
Feb 21, 2023
Nov 14, 2023
Oct 18, 2023
Oct 18, 2023
Aug 12, 2024
Mar 29, 2025
Mar 29, 2025
Aug 12, 2024
Feb 21, 2023

Repository files navigation

Azure Storage CLI

The Azure Storage CLI is for uploading, fetching and deleting content to and from an Azure blobstore. It is highly inspired by the https://github.com/cloudfoundry/bosh-s3cli.

Usage

Given a JSON config file (config.json)...

{
  "account_name":           "<string> (required)",
  "account_key":            "<string> (required)",
  "container_name":         "<string> (required)",
  "environment":            "<string> (optional, default: 'AzureCloud')",
}
# Command: "put"
# Upload a blob to the blobstore.
./bosh-azure-storage-cli -c config.json put <path/to/file> <remote-blob> 

# Command: "get"
# Fetch a blob from the blobstore.
# Destination file will be overwritten if exists.
./bosh-azure-storage-cli -c config.json get <remote-blob> <path/to/file>

# Command: "delete"
# Remove a blob from the blobstore.
./bosh-azure-storage-cli -c config.json delete <remote-blob>

# Command: "exists"
# Checks if blob exists in the blobstore.
./bosh-azure-storage-cli -c config.json exists <remote-blob>

# Command: "sign"
# Create a self-signed url for a blob in the blobstore.
./bosh-azure-storage-cli -c config.json sign <remote-blob> <get|put> <seconds-to-expiration>

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>

Running tests

Unit tests

Using ginkgo:

go install github.com/onsi/ginkgo/v2/ginkgo
ginkgo --skip-package=integration --randomize-all --cover -v -r

Using go test:

go test $(go list ./... | grep -v integration)

Integration tests

  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. Run integration tests

    go test ./integration/...