package
0.2.16
Repository: https://github.com/lytics/cloudstorage.git
Documentation: pkg.go.dev

# README

azure blog store

Cloudstorage abstraction to Azure Blob storage.

config

Login to your https://portal.azure.com account and click "Storage Accounts" in menu. Then Click the storage account you want.

  • config.Project is required. use "Account" in azure portal. This is the "Name" of cloudstorageazuretesting https://cloudstorageazuretesting.blob.core.windows.net/
  • azure_key from your storage account go to the menu "Access Keys"
  • Bucket go to Containers in the azure storage and get this name.

Example in Go:

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/araddon/gou"
	"google.golang.org/api/iterator"

	"github.com/lytics/cloudstorage"
	"github.com/lytics/cloudstorage/azure"
)

/*

# to use azure tests ensure you have exported

export AZURE_KEY="aaa"
export AZURE_PROJECT="bbb"
export AZURE_BUCKET="cloudstorageunittests"

*/

func main() {
	tmpDir, err := os.MkdirTemp("/tmp", "azure_example")
	if err != nil {
		fmt.Println("Could not create temp dir", err)
		os.Exit(1)
	}
	defer os.RemoveAll(tmpDir)

	conf := &cloudstorage.Config{
		Type:       azure.StoreType,
		AuthMethod: azure.AuthKey,
		Bucket:     os.Getenv("AZURE_BUCKET"),
		Project:    os.Getenv("AZURE_PROJECT"),
		TmpDir:     filepath.Join(tempDir, "localcache", "azure"),
		Settings:   make(gou.JsonHelper),
	}

	conf.Settings[azure.ConfKeyAuthKey] = os.Getenv("AZURE_KEY")

	// Should error with empty config
	store, err := cloudstorage.NewStore(conf)
	if err != nil {
		fmt.Println("Could not get azure store ", err)
		os.Exit(1)
	}

	folders, err := store.Folders(context.Background(), cloudstorage.NewQueryForFolders(""))
	if err != nil {
		fmt.Println("Could not get folders ", err)
		os.Exit(1)
	}
	for _, folder := range folders {
		fmt.Println("found folder: ", folder)
	}

	// Create a search query for all objects
	q := cloudstorage.NewQuery("")
	// Create an Iterator
	iter, err := store.Objects(context.Background(), q)
	if err != nil {
		fmt.Println("Could not get iter ", err)
		os.Exit(1)
	}

	for {
		o, err := iter.Next()
		if err == iterator.Done {
			fmt.Println("done, exiting iterator")
			break
		}
		fmt.Println("found object", o.Name())
	}
}

# Packages

No description provided by the author

# Functions

NewClient create new AWS s3 Client.
NewStore Create AWS S3 storage client of type cloudstorage.Store.

# Constants

AuthKey is for using azure api key.
ConfKeyAuthKey config key name of the azure api key for auth.
StoreType = "azure" this is used to define the storage type to create from cloudstorage.NewStore(config).

# Variables

ErrNoAccessKey error for no azure_key.
ErrNoAuth error for no findable auth.
ErrNoAzureSession no valid session.
PageSize is default page size.
Retries number of times to retry upon failures.

# Structs

No description provided by the author