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