or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
golangpkg:golang/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob@v1.6.4

docs

appendblob.mdblob.mdblockblob.mdclient.mdcontainer.mderrors.mdindex.mdlease.mdpageblob.mdsas.mdservice.md
tile.json

tessl/golang-github-com--azure--azure-sdk-for-go--sdk--storage--azblob

tessl install tessl/golang-github-com--azure--azure-sdk-for-go--sdk--storage--azblob@1.6.0

Azure Blob Storage SDK for Go providing comprehensive blob storage operations including uploads, downloads, container management, and advanced features like leases and SAS generation

service.mddocs/

Service Client (service.Client)

The service client manages account-level operations including properties, statistics, user delegation keys, container management, and batch operations.

Package Import

import "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service"

Client Type

type Client struct {
    // contains filtered or unexported fields
}

Constructors

// Create with Azure AD credential
func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error)

// Create with shared key credential
func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error)

// Create from connection string
func NewClientFromConnectionString(connectionString string, options *ClientOptions) (*Client, error)

// Create without credential (for SAS URLs)
func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Client, error)

Service Operations

URL

func (s *Client) URL() string

Returns the service URL endpoint.

GetAccountInfo

func (s *Client) GetAccountInfo(ctx context.Context, o *GetAccountInfoOptions) (GetAccountInfoResponse, error)

Retrieves account-level information including account kind and SKU.

GetProperties

func (s *Client) GetProperties(ctx context.Context, o *GetPropertiesOptions) (GetPropertiesResponse, error)

Gets the Blob service properties including CORS rules, logging, and metrics configuration.

SetProperties

func (s *Client) SetProperties(ctx context.Context, o *SetPropertiesOptions) (SetPropertiesResponse, error)

Sets the Blob service properties.

Options:

type SetPropertiesOptions struct {
    CORS                  []*CORSRule
    DefaultServiceVersion *string
    DeleteRetentionPolicy *RetentionPolicy
    HourMetrics           *Metrics
    Logging               *Logging
    MinuteMetrics         *Metrics
    StaticWebsite         *StaticWebsite
}

GetStatistics

func (s *Client) GetStatistics(ctx context.Context, o *GetStatisticsOptions) (GetStatisticsResponse, error)

Retrieves geo-replication statistics. Only available for read-access geo-redundant replication.

Container Operations

NewContainerClient

func (s *Client) NewContainerClient(containerName string) *container.Client

Creates a container client for the specified container.

CreateContainer

func (s *Client) CreateContainer(ctx context.Context, containerName string, options *CreateContainerOptions) (CreateContainerResponse, error)

Creates a new container.

DeleteContainer

func (s *Client) DeleteContainer(ctx context.Context, containerName string, options *DeleteContainerOptions) (DeleteContainerResponse, error)

Deletes a container.

RestoreContainer

func (s *Client) RestoreContainer(ctx context.Context, deletedContainerName string, deletedContainerVersion string, options *RestoreContainerOptions) (RestoreContainerResponse, error)

Restores a soft-deleted container within the retention period.

NewListContainersPager

func (s *Client) NewListContainersPager(o *ListContainersOptions) *runtime.Pager[ListContainersResponse]

Returns a pager for listing containers.

Options:

type ListContainersOptions struct {
    Include    ListContainersInclude
    Marker     *string
    MaxResults *int32
    Prefix     *string
}

type ListContainersInclude struct {
    Metadata bool
    Deleted  bool
    System   bool
}

Blob Operations

FilterBlobs

func (s *Client) FilterBlobs(ctx context.Context, where string, o *FilterBlobsOptions) (FilterBlobsResponse, error)

Finds blobs matching a tag query expression across all containers.

Example:

// Find blobs with specific tags
where := "\"Status\"='Active' AND \"Priority\"='High'"
resp, err := serviceClient.FilterBlobs(ctx, where, nil)

Batch Operations

NewBatchBuilder

func (s *Client) NewBatchBuilder() (*BatchBuilder, error)

Creates a batch builder for adding multiple operations to execute as a batch.

SubmitBatch

func (s *Client) SubmitBatch(ctx context.Context, bb *BatchBuilder, options *SubmitBatchOptions) (SubmitBatchResponse, error)

Submits a batch of operations.

Example:

// Create batch
batch, err := serviceClient.NewBatchBuilder()
if err != nil {
    // handle error
}

// Add operations
err = batch.Delete("container1", "blob1", nil)
err = batch.Delete("container1", "blob2", nil)
err = batch.SetTier("container2", "blob3", blob.AccessTierCool, nil)

// Submit batch
resp, err := serviceClient.SubmitBatch(ctx, batch, nil)

BatchBuilder

type BatchBuilder struct {
    // contains filtered or unexported fields
}

// Add delete operation
func (bb *BatchBuilder) Delete(containerName string, blobName string, options *BatchDeleteOptions) error

// Add set tier operation
func (bb *BatchBuilder) SetTier(containerName string, blobName string, accessTier blob.AccessTier, options *BatchSetTierOptions) error

User Delegation

GetUserDelegationCredential

func (s *Client) GetUserDelegationCredential(ctx context.Context, info KeyInfo, o *GetUserDelegationCredentialOptions) (*UserDelegationCredential, error)

Obtains a user delegation key for creating user delegation SAS tokens. Requires OAuth authentication.

Types:

type KeyInfo struct {
    Start  *time.Time
    Expiry *time.Time
}

type UserDelegationCredential struct {
    // contains filtered or unexported fields
}

SAS Generation

GetSASURL

func (s *Client) GetSASURL(resources sas.AccountResourceTypes, permissions sas.AccountPermissions, expiry time.Time, o *GetSASURLOptions) (string, error)

Generates an account-level SAS URL. Requires SharedKeyCredential.

Example:

import (
    "time"
    "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/sas"
)

// Set permissions
permissions := sas.AccountPermissions{
    Read:   true,
    Write:  true,
    List:   true,
    Create: true,
}

// Set resource types
resources := sas.AccountResourceTypes{
    Service:   true,
    Container: true,
    Object:    true,
}

// Generate SAS URL
expiry := time.Now().Add(24 * time.Hour)
sasURL, err := serviceClient.GetSASURL(resources, permissions, expiry, nil)

Constants

const (
    ContainerNameRoot = "$root" // Root container name
    ContainerNameLogs = "$logs" // Logs container name
)

Types

Service Properties

type StorageServiceProperties struct {
    CORS                  []*CORSRule
    DefaultServiceVersion *string
    DeleteRetentionPolicy *RetentionPolicy
    HourMetrics           *Metrics
    Logging               *Logging
    MinuteMetrics         *Metrics
    StaticWebsite         *StaticWebsite
}

type CORSRule struct {
    AllowedOrigins  *string
    AllowedMethods  *string
    AllowedHeaders  *string
    ExposedHeaders  *string
    MaxAgeInSeconds *int32
}

type Logging struct {
    Version         *string
    Delete          *bool
    Read            *bool
    Write           *bool
    RetentionPolicy *RetentionPolicy
}

type Metrics struct {
    Version         *string
    Enabled         *bool
    IncludeAPIs     *bool
    RetentionPolicy *RetentionPolicy
}

type RetentionPolicy struct {
    Enabled *bool
    Days    *int32
}

type StaticWebsite struct {
    Enabled              *bool
    IndexDocument        *string
    ErrorDocument404Path *string
    DefaultIndexDocumentPath *string
}

Statistics

type StorageServiceStats struct {
    GeoReplication *GeoReplication
}

type GeoReplication struct {
    Status       *BlobGeoReplicationStatus
    LastSyncTime *time.Time
}

Container Types

type ContainerItem struct {
    Name       *string
    Version    *string
    Deleted    *bool
    Properties *ContainerProperties
    Metadata   map[string]*string
}

type ContainerProperties struct {
    LastModified                   *time.Time
    ETag                           *azcore.ETag
    LeaseStatus                    *LeaseStatusType
    LeaseState                     *LeaseStateType
    LeaseDuration                  *LeaseDurationType
    PublicAccess                   *PublicAccessType
    HasImmutabilityPolicy          *bool
    HasLegalHold                   *bool
    DefaultEncryptionScope         *string
    PreventEncryptionScopeOverride *bool
    DeletedTime                    *time.Time
    RemainingRetentionDays         *int32
    IsImmutableStorageWithVersioningEnabled *bool
}

Filter Types

type FilterBlobItem struct {
    Name          *string
    ContainerName *string
    Tags          *BlobTags
}

type FilterBlobSegment struct {
    BlobItems  []*FilterBlobItem
    NextMarker *string
}

type BlobTag struct {
    Key   *string
    Value *string
}

type BlobTags struct {
    BlobTagSet []*BlobTag
}

Batch Types

type BatchDeleteOptions struct {
    DeleteSnapshots  *DeleteSnapshotsOptionType
    BlobDeleteType   *DeleteType
    AccessConditions *blob.AccessConditions
    VersionID        *string
    Snapshot         *string
}

type BatchSetTierOptions struct {
    RehydratePriority *RehydratePriority
    AccessConditions  *blob.AccessConditions
    VersionID         *string
    Snapshot          *string
}

type BatchResponseItem struct {
    ContainerName *string
    BlobName      *string
    RequestID     *string
    Version       *string
    Date          *time.Time
    ETag          *azcore.ETag
    // Error information if operation failed
    ErrorCode    *string
    ErrorMessage *string
}

Enums

Account Kind

type AccountKind string

const (
    AccountKindStorage          AccountKind = "Storage"
    AccountKindBlobStorage      AccountKind = "BlobStorage"
    AccountKindStorageV2        AccountKind = "StorageV2"
    AccountKindFileStorage      AccountKind = "FileStorage"
    AccountKindBlockBlobStorage AccountKind = "BlockBlobStorage"
)

SKU Name

type SKUName string

const (
    SKUNameStandardLRS   SKUName = "Standard_LRS"
    SKUNameStandardGRS   SKUName = "Standard_GRS"
    SKUNameStandardRAGRS SKUName = "Standard_RAGRS"
    SKUNameStandardZRS   SKUName = "Standard_ZRS"
    SKUNamePremiumLRS    SKUName = "Premium_LRS"
)

Geo-Replication Status

type BlobGeoReplicationStatus string

const (
    BlobGeoReplicationStatusLive        BlobGeoReplicationStatus = "live"
    BlobGeoReplicationStatusBootstrap   BlobGeoReplicationStatus = "bootstrap"
    BlobGeoReplicationStatusUnavailable BlobGeoReplicationStatus = "unavailable"
)

Public Access Type

type PublicAccessType string

const (
    PublicAccessTypeBlob      PublicAccessType = "blob"
    PublicAccessTypeContainer PublicAccessType = "container"
)

List Containers Include

type ListContainersIncludeType string

const (
    ListContainersIncludeTypeMetadata ListContainersIncludeType = "metadata"
    ListContainersIncludeTypeDeleted  ListContainersIncludeType = "deleted"
    ListContainersIncludeTypeSystem   ListContainersIncludeType = "system"
)

Shared Key Credential

type SharedKeyCredential struct {
    // contains filtered or unexported fields
}

func NewSharedKeyCredential(accountName, accountKey string) (*SharedKeyCredential, error)

func (c *SharedKeyCredential) AccountName() string

Client Options

type ClientOptions struct {
    Telemetry                       policy.TelemetryOptions
    Transport                       policy.Transporter
    Retry                           policy.RetryOptions
    PerCallPolicies                 []policy.Policy
    PerRetryPolicies                []policy.Policy
    InsecureAllowCredentialWithHTTP bool
    DisableRPRegistration           bool
}