Documentation
¶
Overview ¶
Example (Service_Client_CreateContainer) ¶
package main import ( "context" "fmt" "log" "os" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/", accountName) cred, err := azidentity.NewDefaultAzureCredential(nil) handleError(err) serviceClient, err := service.NewClient(serviceURL, cred, nil) handleError(err) _, err = serviceClient.CreateContainer(context.TODO(), "testcontainer", nil) handleError(err) // ======== 2. Delete a container ======== defer func(serviceClient1 *service.Client, ctx context.Context, containerName string, options *container.DeleteOptions) { _, err = serviceClient1.DeleteContainer(ctx, containerName, options) if err != nil { log.Fatal(err) } }(serviceClient, context.TODO(), "testcontainer", nil) }
Output:
Example (Service_Client_DeleteContainer) ¶
package main import ( "context" "fmt" "log" "os" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/", accountName) cred, err := azidentity.NewDefaultAzureCredential(nil) handleError(err) serviceClient, err := service.NewClient(serviceURL, cred, nil) handleError(err) _, err = serviceClient.DeleteContainer(context.TODO(), "testcontainer", nil) handleError(err) }
Output:
Example (Service_Client_GetProperties) ¶
package main import ( "context" "fmt" "log" "os" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/", accountName) cred, err := azidentity.NewDefaultAzureCredential(nil) handleError(err) serviceClient, err := service.NewClient(serviceURL, cred, nil) handleError(err) serviceGetPropertiesResponse, err := serviceClient.GetProperties(context.TODO(), nil) handleError(err) fmt.Println(serviceGetPropertiesResponse) }
Output:
Example (Service_Client_GetSASURL) ¶
package main import ( "fmt" "log" "time" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/sas" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { cred, err := azblob.NewSharedKeyCredential("myAccountName", "myAccountKey") handleError(err) serviceClient, err := service.NewClientWithSharedKeyCredential("https://<myAccountName>.blob.core.windows.net", cred, nil) handleError(err) resources := sas.AccountResourceTypes{Service: true} permission := sas.AccountPermissions{Read: true} start := time.Now() expiry := start.AddDate(1, 0, 0) sasURL, err := serviceClient.GetSASURL(resources, permission, sas.AccountServices{Blob: true}, start, expiry) handleError(err) serviceURL := fmt.Sprintf("https://<myAccountName>.blob.core.windows.net/?%s", sasURL) serviceClientWithSAS, err := service.NewClientWithNoCredential(serviceURL, nil) handleError(err) _ = serviceClientWithSAS }
Output:
Example (Service_Client_ListContainers) ¶
package main import ( "context" "fmt" "log" "os" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/", accountName) cred, err := azidentity.NewDefaultAzureCredential(nil) handleError(err) serviceClient, err := service.NewClient(serviceURL, cred, nil) handleError(err) listContainersOptions := service.ListContainersOptions{ Include: service.ListContainersInclude{ Metadata: true, // Include Metadata Deleted: true, // Include deleted containers in the result as well }, } pager := serviceClient.NewListContainersPager(&listContainersOptions) for pager.More() { resp, err := pager.NextPage(context.TODO()) if err != nil { log.Fatal(err) } for _, container := range resp.ContainerItems { fmt.Println(*container.Name) } } }
Output:
Example (Service_Client_NewClient) ¶
package main import ( "fmt" "log" "os" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/", accountName) cred, err := azidentity.NewDefaultAzureCredential(nil) handleError(err) serviceClient, err := service.NewClient(serviceURL, cred, nil) handleError(err) fmt.Println(serviceClient.URL()) }
Output:
Example (Service_Client_NewClientFromConnectionString) ¶
package main import ( "fmt" "log" "os" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { // Your connection string can be obtained from the Azure Portal. connectionString, ok := os.LookupEnv("AZURE_STORAGE_CONNECTION_STRING") if !ok { log.Fatal("the environment variable 'AZURE_STORAGE_CONNECTION_STRING' could not be found") } serviceClient, err := service.NewClientFromConnectionString(connectionString, nil) handleError(err) fmt.Println(serviceClient.URL()) }
Output:
Example (Service_Client_NewClientWithNoCredential) ¶
package main import ( "fmt" "log" "os" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } sharedAccessSignature, ok := os.LookupEnv("AZURE_STORAGE_SHARED_ACCESS_SIGNATURE") if !ok { panic("AZURE_STORAGE_SHARED_ACCESS_SIGNATURE could not be found") } serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/?%s", accountName, sharedAccessSignature) serviceClient, err := service.NewClientWithNoCredential(serviceURL, nil) handleError(err) fmt.Println(serviceClient.URL()) }
Output:
Example (Service_Client_NewClientWithUserDelegationCredential) ¶
package main import ( "context" "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/generated" "log" "os" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/sas" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } // Create Managed Identity (OAuth) Credentials using Client ID clientOptions := azcore.ClientOptions{} // Fill clientOptions as needed optsClientID := azidentity.ManagedIdentityCredentialOptions{ClientOptions: clientOptions, ID: azidentity.ClientID("7cf7db0d-...")} cred, err := azidentity.NewManagedIdentityCredential(&optsClientID) handleError(err) clientOptionsService := service.ClientOptions{} // Same as azcore.ClientOptions using service instead svcClient, err := service.NewClient(fmt.Sprintf("https://%s.blob.core.windows.net/", accountName), cred, &clientOptionsService) handleError(err) // Set current and past time and create key currentTime := time.Now().UTC().Add(-10 * time.Second) pastTime := currentTime.Add(48 * time.Hour) info := generated.KeyInfo{ Start: to.Ptr(currentTime.UTC().Format(sas.TimeFormat)), Expiry: to.Ptr(pastTime.UTC().Format(sas.TimeFormat)), } udc, err := svcClient.GetUserDelegationCredential(context.Background(), info, nil) handleError(err) fmt.Println("User Delegation Key has been created for ", accountName) // Create Account Signature Values with desired permissions and sign with user delegation credential sasQueryParams, err := sas.AccountSignatureValues{ Protocol: sas.ProtocolHTTPS, ExpiryTime: time.Now().UTC().Add(48 * time.Hour), Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true}).String(), Services: to.Ptr(sas.AccountServices{Blob: true}).String(), ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(), }.SignWithUserDelegation(udc) handleError(err) sasURL := fmt.Sprintf("https://%s.blob.core.windows.net/?%s", accountName, sasQueryParams.Encode()) // This URL can be used to authenticate requests now serviceClient, err := service.NewClientWithNoCredential(sasURL, nil) handleError(err) // You can also break a blob URL up into it's constituent parts blobURLParts, _ := blob.ParseURL(serviceClient.URL()) fmt.Printf("SAS expiry time = %s\n", blobURLParts.SAS.ExpiryTime()) // Create Managed Identity (OAuth) Credentials using Resource ID optsResourceID := azidentity.ManagedIdentityCredentialOptions{ClientOptions: clientOptions, ID: azidentity.ResourceID("/subscriptions/...")} cred, err = azidentity.NewManagedIdentityCredential(&optsResourceID) handleError(err) svcClient, err = service.NewClient("svcURL", cred, &clientOptionsService) handleError(err) udc, err = svcClient.GetUserDelegationCredential(context.Background(), info, nil) handleError(err) fmt.Println("User Delegation Key has been created for ", accountName) // Create Account Signature Values with desired permissions and sign with user delegation credential sasQueryParams, err = sas.AccountSignatureValues{ Protocol: sas.ProtocolHTTPS, ExpiryTime: time.Now().UTC().Add(48 * time.Hour), Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true}).String(), Services: to.Ptr(sas.AccountServices{Blob: true}).String(), ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(), }.SignWithUserDelegation(udc) handleError(err) sasURL = fmt.Sprintf("https://%s.blob.core.windows.net/?%s", accountName, sasQueryParams.Encode()) // This URL can be used to authenticate requests now serviceClient, err = service.NewClientWithNoCredential(sasURL, nil) handleError(err) // You can also break a blob URL up into it's constituent parts blobURLParts, _ = blob.ParseURL(serviceClient.URL()) fmt.Printf("SAS expiry time = %s\n", blobURLParts.SAS.ExpiryTime()) }
Output:
Example (Service_Client_RestoreContainer) ¶
package main import ( "context" "fmt" "log" "os" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/", accountName) cred, err := azidentity.NewDefaultAzureCredential(nil) handleError(err) serviceClient, err := service.NewClient(serviceURL, cred, nil) handleError(err) listOptions := service.ListContainersOptions{ Include: service.ListContainersInclude{ Metadata: true, // Include Metadata Deleted: true, // Include deleted containers in the result as well }, } pager := serviceClient.NewListContainersPager(&listOptions) for pager.More() { resp, err := pager.NextPage(context.TODO()) if err != nil { log.Fatal(err) } for _, cont := range resp.ContainerItems { if *cont.Deleted { _, err = serviceClient.RestoreContainer(context.TODO(), *cont.Name, *cont.Version, nil) handleError(err) } } } }
Output:
Example (Service_Client_SetProperties) ¶
package main import ( "context" "fmt" "log" "os" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/", accountName) cred, err := azidentity.NewDefaultAzureCredential(nil) handleError(err) serviceClient, err := service.NewClient(serviceURL, cred, nil) handleError(err) enabled := true // enabling retention period days := int32(5) // setting retention period to 5 days serviceSetPropertiesResponse, err := serviceClient.SetProperties(context.TODO(), &service.SetPropertiesOptions{ DeleteRetentionPolicy: &service.RetentionPolicy{Enabled: &enabled, Days: &days}, }) handleError(err) fmt.Println(serviceSetPropertiesResponse) }
Output:
Example (Service_SASSignatureValues_Sign) ¶
This example shows how to create and use an Azure Storage account Shared Access Signature (SAS).
package main import ( "fmt" "log" "os" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/sas" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" ) func handleError(err error) { if err != nil { log.Fatal(err.Error()) } } func main() { accountName, accountKey := os.Getenv("AZURE_STORAGE_ACCOUNT_NAME"), os.Getenv("AZURE_STORAGE_ACCOUNT_KEY") credential, err := azblob.NewSharedKeyCredential(accountName, accountKey) handleError(err) sasQueryParams, err := sas.AccountSignatureValues{ Protocol: sas.ProtocolHTTPS, ExpiryTime: time.Now().UTC().Add(48 * time.Hour), Permissions: to.Ptr(sas.AccountPermissions{Read: true, List: true}).String(), Services: to.Ptr(sas.AccountServices{Blob: true}).String(), ResourceTypes: to.Ptr(sas.AccountResourceTypes{Container: true, Object: true}).String(), }.SignWithSharedKey(credential) handleError(err) sasURL := fmt.Sprintf("https://%s.blob.core.windows.net/?%s", accountName, sasQueryParams.Encode()) // This URL can be used to authenticate requests now serviceClient, err := service.NewClientWithNoCredential(sasURL, nil) handleError(err) // You can also break a blob URL up into it's constituent parts blobURLParts, _ := blob.ParseURL(serviceClient.URL()) fmt.Printf("SAS expiry time = %s\n", blobURLParts.SAS.ExpiryTime()) }
Output:
Index ¶
- Constants
- type AccessConditions
- type AccountKind
- type BlobGeoReplicationStatus
- type Client
- func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error)
- func NewClientFromConnectionString(connectionString string, options *ClientOptions) (*Client, error)
- func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Client, error)
- func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error)
- func (s *Client) CreateContainer(ctx context.Context, containerName string, options *CreateContainerOptions) (CreateContainerResponse, error)
- func (s *Client) DeleteContainer(ctx context.Context, containerName string, options *DeleteContainerOptions) (DeleteContainerResponse, error)
- func (s *Client) FilterBlobs(ctx context.Context, o *FilterBlobsOptions) (FilterBlobsResponse, error)
- func (s *Client) GetAccountInfo(ctx context.Context, o *GetAccountInfoOptions) (GetAccountInfoResponse, error)
- func (s *Client) GetProperties(ctx context.Context, o *GetPropertiesOptions) (GetPropertiesResponse, error)
- func (s *Client) GetSASURL(resources sas.AccountResourceTypes, permissions sas.AccountPermissions, ...) (string, error)
- func (s *Client) GetStatistics(ctx context.Context, o *GetStatisticsOptions) (GetStatisticsResponse, error)
- func (s *Client) GetUserDelegationCredential(ctx context.Context, info KeyInfo, o *GetUserDelegationCredentialOptions) (*UserDelegationCredential, error)
- func (s *Client) NewContainerClient(containerName string) *container.Client
- func (s *Client) NewListContainersPager(o *ListContainersOptions) *runtime.Pager[ListContainersResponse]
- func (s *Client) RestoreContainer(ctx context.Context, deletedContainerName string, ...) (RestoreContainerResponse, error)
- func (s *Client) SetProperties(ctx context.Context, o *SetPropertiesOptions) (SetPropertiesResponse, error)
- func (s *Client) URL() string
- type ClientOptions
- type CorsRule
- type CpkInfo
- type CpkScopeInfo
- type CreateContainerOptions
- type CreateContainerResponse
- type DeleteContainerOptions
- type DeleteContainerResponse
- type FilterBlobsOptions
- type FilterBlobsResponse
- type GetAccountInfoOptions
- type GetAccountInfoResponse
- type GetPropertiesOptions
- type GetPropertiesResponse
- type GetStatisticsOptions
- type GetStatisticsResponse
- type GetUserDelegationCredentialOptions
- type GetUserDelegationKeyResponse
- type KeyInfo
- type ListContainersInclude
- type ListContainersIncludeType
- type ListContainersOptions
- type ListContainersResponse
- type Logging
- type Metrics
- type PublicAccessType
- type RestoreContainerOptions
- type RestoreContainerResponse
- type RetentionPolicy
- type SKUName
- type SetPropertiesOptions
- type SetPropertiesResponse
- type SharedKeyCredential
- type StaticWebsite
- type StorageServiceProperties
- type StorageServiceStats
- type UserDelegationCredential
- type UserDelegationKey
Examples ¶
- Package (Service_Client_CreateContainer)
- Package (Service_Client_DeleteContainer)
- Package (Service_Client_GetProperties)
- Package (Service_Client_GetSASURL)
- Package (Service_Client_ListContainers)
- Package (Service_Client_NewClient)
- Package (Service_Client_NewClientFromConnectionString)
- Package (Service_Client_NewClientWithNoCredential)
- Package (Service_Client_NewClientWithSharedKeyCredential)
- Package (Service_Client_NewClientWithUserDelegationCredential)
- Package (Service_Client_RestoreContainer)
- Package (Service_Client_SetProperties)
- Package (Service_SASSignatureValues_Sign)
Constants ¶
const ( // ContainerNameRoot is the special Azure Storage name used to identify a storage account's root container. ContainerNameRoot = "$root" // ContainerNameLogs is the special Azure Storage name used to identify a storage account's logs container. ContainerNameLogs = "$logs" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessConditions ¶
type AccessConditions = exported.ContainerAccessConditions
AccessConditions identifies container-specific access conditions which you optionally set.
type AccountKind ¶
type AccountKind = generated.AccountKind
AccountKind defines values for AccountKind
const ( AccountKindStorage AccountKind = generated.AccountKindStorage AccountKindBlobStorage AccountKind = generated.AccountKindBlobStorage AccountKindStorageV2 AccountKind = generated.AccountKindStorageV2 AccountKindFileStorage AccountKind = generated.AccountKindFileStorage AccountKindBlockBlobStorage AccountKind = generated.AccountKindBlockBlobStorage )
func PossibleAccountKindValues ¶
func PossibleAccountKindValues() []AccountKind
PossibleAccountKindValues returns the possible values for the AccountKind const type.
type BlobGeoReplicationStatus ¶
type BlobGeoReplicationStatus = generated.BlobGeoReplicationStatus
BlobGeoReplicationStatus - The status of the secondary location
const ( BlobGeoReplicationStatusLive BlobGeoReplicationStatus = generated.BlobGeoReplicationStatusLive BlobGeoReplicationStatusBootstrap BlobGeoReplicationStatus = generated.BlobGeoReplicationStatusBootstrap )
func PossibleBlobGeoReplicationStatusValues ¶
func PossibleBlobGeoReplicationStatusValues() []BlobGeoReplicationStatus
PossibleBlobGeoReplicationStatusValues returns the possible values for the BlobGeoReplicationStatus const type.
type Client ¶
type Client base.Client[generated.ServiceClient]
Client represents a URL to the Azure Blob Storage service allowing you to manipulate blob containers.
func NewClient ¶
func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error)
NewClient creates an instance of Client with the specified values.
- serviceURL - the URL of the storage account e.g. https://<account>.blob.core.windows.net/
- cred - an Azure AD credential, typically obtained via the azidentity module
- options - client options; pass nil to accept the default values
func NewClientFromConnectionString ¶
func NewClientFromConnectionString(connectionString string, options *ClientOptions) (*Client, error)
NewClientFromConnectionString creates an instance of Client with the specified values.
- connectionString - a connection string for the desired storage account
- options - client options; pass nil to accept the default values
func NewClientWithNoCredential ¶
func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Client, error)
NewClientWithNoCredential creates an instance of Client with the specified values. This is used to anonymously access a storage account or with a shared access signature (SAS) token.
- serviceURL - the URL of the storage account e.g. https://<account>.blob.core.windows.net/?<sas token>
- options - client options; pass nil to accept the default values
func NewClientWithSharedKeyCredential ¶
func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error)
NewClientWithSharedKeyCredential creates an instance of Client with the specified values.
- serviceURL - the URL of the storage account e.g. https://<account>.blob.core.windows.net/
- cred - a SharedKeyCredential created with the matching storage account and access key
- options - client options; pass nil to accept the default values
func (*Client) CreateContainer ¶
func (s *Client) CreateContainer(ctx context.Context, containerName string, options *CreateContainerOptions) (CreateContainerResponse, error)
CreateContainer is a lifecycle method to creates a new container under the specified account. If the container with the same name already exists, a ResourceExistsError will be raised. This method returns a client with which to interact with the newly created container.
func (*Client) DeleteContainer ¶
func (s *Client) DeleteContainer(ctx context.Context, containerName string, options *DeleteContainerOptions) (DeleteContainerResponse, error)
DeleteContainer is a lifecycle method that marks the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection. If the container is not found, a ResourceNotFoundError will be raised.
func (*Client) FilterBlobs ¶
func (s *Client) FilterBlobs(ctx context.Context, o *FilterBlobsOptions) (FilterBlobsResponse, error)
FilterBlobs operation finds all blobs in the storage account whose tags match a given search expression. Filter blobs searches across all containers within a storage account but can be scoped within the expression to a single container. https://docs.microsoft.com/en-us/rest/api/storageservices/find-blobs-by-tags eg. "dog='germanshepherd' and penguin='emperorpenguin'" To specify a container, eg. "@container=’containerName’ and Name = ‘C’"
func (*Client) GetAccountInfo ¶
func (s *Client) GetAccountInfo(ctx context.Context, o *GetAccountInfoOptions) (GetAccountInfoResponse, error)
GetAccountInfo provides account level information
func (*Client) GetProperties ¶
func (s *Client) GetProperties(ctx context.Context, o *GetPropertiesOptions) (GetPropertiesResponse, error)
GetProperties - gets the properties of a storage account's Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules.
func (*Client) GetSASURL ¶
func (s *Client) GetSASURL(resources sas.AccountResourceTypes, permissions sas.AccountPermissions, services sas.AccountServices, start time.Time, expiry time.Time) (string, error)
GetSASURL is a convenience method for generating a SAS token for the currently pointed at account. It can only be used if the credential supplied during creation was a SharedKeyCredential. This validity can be checked with CanGetAccountSASToken().
func (*Client) GetStatistics ¶
func (s *Client) GetStatistics(ctx context.Context, o *GetStatisticsOptions) (GetStatisticsResponse, error)
GetStatistics Retrieves statistics related to replication for the Blob service. It is only available when read-access geo-redundant replication is enabled for the storage account. With geo-redundant replication, Azure Storage maintains your data durable in two locations. In both locations, Azure Storage constantly maintains multiple healthy replicas of your data. The location where you read, create, update, or delete data is the primary storage account location. The primary location exists in the region you choose at the time you create an account via the Azure Management Azure classic portal, for example, North Central US. The location to which your data is replicated is the secondary location. The secondary location is automatically determined based on the location of the primary; it is in a second data center that resides in the same region as the primary location. Read-only access is available from the secondary location, if read-access geo-redundant replication is enabled for your storage account.
func (*Client) GetUserDelegationCredential ¶
func (s *Client) GetUserDelegationCredential(ctx context.Context, info KeyInfo, o *GetUserDelegationCredentialOptions) (*UserDelegationCredential, error)
GetUserDelegationCredential obtains a UserDelegationKey object using the base ServiceURL object. OAuth is required for this call, as well as any role that can delegate access to the storage account.
func (*Client) NewContainerClient ¶
NewContainerClient creates a new ContainerClient object by concatenating containerName to the end of Client's URL. The new ContainerClient uses the same request policy pipeline as the Client. To change the pipeline, create the ContainerClient and then call its WithPipeline method passing in the desired pipeline object. Or, call this package's NewContainerClient instead of calling this object's NewContainerClient method.
func (*Client) NewListContainersPager ¶
func (s *Client) NewListContainersPager(o *ListContainersOptions) *runtime.Pager[ListContainersResponse]
NewListContainersPager operation returns a pager of the containers under the specified account. Use an empty Marker to start enumeration from the beginning. Container names are returned in lexicographic order. For more information, see https://docs.microsoft.com/rest/api/storageservices/list-containers2.
func (*Client) RestoreContainer ¶
func (s *Client) RestoreContainer(ctx context.Context, deletedContainerName string, deletedContainerVersion string, options *RestoreContainerOptions) (RestoreContainerResponse, error)
RestoreContainer restores soft-deleted container Operation will only be successful if used within the specified number of days set in the delete retention policy
func (*Client) SetProperties ¶
func (s *Client) SetProperties(ctx context.Context, o *SetPropertiesOptions) (SetPropertiesResponse, error)
SetProperties Sets the properties of a storage account's Blob service, including Azure Storage Analytics. If an element (e.g. analytics_logging) is left as None, the existing settings on the service for that functionality are preserved.
type ClientOptions ¶
type ClientOptions struct {
azcore.ClientOptions
}
ClientOptions contains the optional parameters when creating a Client.
type CorsRule ¶
CorsRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in another domain. Web browsers implement a security restriction known as same-origin policy that prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs in another domain
type CpkScopeInfo ¶
type CpkScopeInfo = generated.CpkScopeInfo
CpkScopeInfo contains a group of parameters for the BlobClient.SetMetadata method.
type CreateContainerOptions ¶
type CreateContainerOptions = container.CreateOptions
CreateContainerOptions contains the optional parameters for the container.Client.Create method.
type CreateContainerResponse ¶
type CreateContainerResponse = generated.ContainerClientCreateResponse
CreateContainerResponse contains the response from method container.Client.Create.
type DeleteContainerOptions ¶
type DeleteContainerOptions = container.DeleteOptions
DeleteContainerOptions contains the optional parameters for the container.Client.Delete method.
type DeleteContainerResponse ¶
type DeleteContainerResponse = generated.ContainerClientDeleteResponse
DeleteContainerResponse contains the response from method container.Client.Delete
type FilterBlobsOptions ¶
type FilterBlobsOptions struct { // A string value that identifies the portion of the list of containers to be returned with the next listing operation. The // operation returns the NextMarker value within the response body if the listing // operation did not return all containers remaining to be listed with the current page. The NextMarker value can be used // as the value for the marker parameter in a subsequent call to request the next // page of list items. The marker value is opaque to the client. Marker *string // Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value // greater than 5000, the server will return up to 5000 items. Note that if the // listing operation crosses a partition boundary, then the service will return a continuation token for retrieving the remainder // of the results. For this reason, it is possible that the service will // return fewer results than specified by maxresults, or than the default of 5000. MaxResults *int32 // Filters the results to return only to return only blobs whose tags match the specified expression. Where *string }
FilterBlobsOptions provides set of options for Client.FindBlobsByTags
type FilterBlobsResponse ¶
type FilterBlobsResponse = generated.ServiceClientFilterBlobsResponse
FilterBlobsResponse contains the response from method Client.FilterBlobs.
type GetAccountInfoOptions ¶
type GetAccountInfoOptions struct { }
GetAccountInfoOptions provides set of options for Client.GetAccountInfo
type GetAccountInfoResponse ¶
type GetAccountInfoResponse = generated.ServiceClientGetAccountInfoResponse
GetAccountInfoResponse contains the response from method Client.GetAccountInfo.
type GetPropertiesOptions ¶
type GetPropertiesOptions struct { }
GetPropertiesOptions contains the optional parameters for the Client.GetProperties method.
type GetPropertiesResponse ¶
type GetPropertiesResponse = generated.ServiceClientGetPropertiesResponse
GetPropertiesResponse contains the response from method Client.GetProperties.
type GetStatisticsOptions ¶
type GetStatisticsOptions struct { }
GetStatisticsOptions provides set of options for Client.GetStatistics
type GetStatisticsResponse ¶
type GetStatisticsResponse = generated.ServiceClientGetStatisticsResponse
GetStatisticsResponse contains the response from method Client.GetStatistics.
type GetUserDelegationCredentialOptions ¶
type GetUserDelegationCredentialOptions struct { }
GetUserDelegationCredentialOptions contains optional parameters for Service.GetUserDelegationKey method
type GetUserDelegationKeyResponse ¶
type GetUserDelegationKeyResponse = generated.ServiceClientGetUserDelegationKeyResponse
GetUserDelegationKeyResponse contains the response from method ServiceClient.GetUserDelegationKey.
type ListContainersInclude ¶
type ListContainersInclude struct { // Tells the service whether to return metadata for each container. Metadata bool // Tells the service whether to return soft-deleted containers. Deleted bool }
ListContainersInclude indicates what additional information the service should return with each container.
type ListContainersIncludeType ¶
type ListContainersIncludeType = generated.ListContainersIncludeType
ListContainersIncludeType defines values for ListContainersIncludeType
const ( ListContainersIncludeTypeMetadata ListContainersIncludeType = generated.ListContainersIncludeTypeMetadata ListContainersIncludeTypeDeleted ListContainersIncludeType = generated.ListContainersIncludeTypeDeleted ListContainersIncludeTypeSystem ListContainersIncludeType = generated.ListContainersIncludeTypeSystem )
func PossibleListContainersIncludeTypeValues ¶
func PossibleListContainersIncludeTypeValues() []ListContainersIncludeType
PossibleListContainersIncludeTypeValues returns the possible values for the ListContainersIncludeType const type.
type ListContainersOptions ¶
type ListContainersOptions struct { Include ListContainersInclude // A string value that identifies the portion of the list of containers to be returned with the next listing operation. The // operation returns the NextMarker value within the response body if the listing operation did not return all containers // remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in // a subsequent call to request the next page of list items. The marker value is opaque to the client. Marker *string // Specifies the maximum number of containers to return. If the request does not specify max results, or specifies a value // greater than 5000, the server will return up to 5000 items. Note that if the listing operation crosses a partition boundary, // then the service will return a continuation token for retrieving the remainder of the results. For this reason, it is possible // that the service will return fewer results than specified by max results, or than the default of 5000. MaxResults *int32 // Filters the results to return only containers whose name begins with the specified prefix. Prefix *string }
ListContainersOptions provides set of configurations for ListContainers operation
type ListContainersResponse ¶
type ListContainersResponse = generated.ServiceClientListContainersSegmentResponse
ListContainersResponse contains the response from method Client.ListContainersSegment.
type Metrics ¶
Metrics - a summary of request statistics grouped by API in hour or minute aggregates for blobs
type PublicAccessType ¶
type PublicAccessType = generated.PublicAccessType
PublicAccessType defines values for AccessType - private (default) or blob or container
const ( PublicAccessTypeBlob PublicAccessType = generated.PublicAccessTypeBlob PublicAccessTypeContainer PublicAccessType = generated.PublicAccessTypeContainer )
func PossiblePublicAccessTypeValues ¶
func PossiblePublicAccessTypeValues() []PublicAccessType
PossiblePublicAccessTypeValues returns the possible values for the PublicAccessType const type.
type RestoreContainerOptions ¶
type RestoreContainerOptions = container.RestoreOptions
RestoreContainerOptions contains the optional parameters for the container.Client.Restore method.
type RestoreContainerResponse ¶
type RestoreContainerResponse = generated.ContainerClientRestoreResponse
RestoreContainerResponse contains the response from method container.Client.Restore
type RetentionPolicy ¶
type RetentionPolicy = generated.RetentionPolicy
RetentionPolicy - the retention policy which determines how long the associated data should persist
type SKUName ¶
SKUName defines values for SkuName - LRS, GRS, RAGRS, ZRS, Premium LRS
const ( SKUNameStandardLRS SKUName = generated.SKUNameStandardLRS SKUNameStandardGRS SKUName = generated.SKUNameStandardGRS SKUNameStandardRAGRS SKUName = generated.SKUNameStandardRAGRS SKUNameStandardZRS SKUName = generated.SKUNameStandardZRS SKUNamePremiumLRS SKUName = generated.SKUNamePremiumLRS )
func PossibleSKUNameValues ¶
func PossibleSKUNameValues() []SKUName
PossibleSKUNameValues returns the possible values for the SKUName const type.
type SetPropertiesOptions ¶
type SetPropertiesOptions struct { // The set of CORS rules. Cors []*CorsRule // The default version to use for requests to the Blob service if an incoming request's version is not specified. Possible // values include version 2008-10-27 and all more recent versions DefaultServiceVersion *string // the retention policy which determines how long the associated data should persist DeleteRetentionPolicy *RetentionPolicy // a summary of request statistics grouped by API in hour or minute aggregates for blobs HourMetrics *Metrics // Azure Analytics Logging settings. Logging *Logging // a summary of request statistics grouped by API in hour or minute aggregates for blobs MinuteMetrics *Metrics // The properties that enable an account to host a static website StaticWebsite *StaticWebsite }
SetPropertiesOptions provides set of options for Client.SetProperties
type SetPropertiesResponse ¶
type SetPropertiesResponse = generated.ServiceClientSetPropertiesResponse
SetPropertiesResponse contains the response from method Client.SetProperties.
type SharedKeyCredential ¶
type SharedKeyCredential = exported.SharedKeyCredential
SharedKeyCredential contains an account's name and its primary or secondary key.
func NewSharedKeyCredential ¶
func NewSharedKeyCredential(accountName, accountKey string) (*SharedKeyCredential, error)
NewSharedKeyCredential creates an immutable SharedKeyCredential containing the storage account's name and either its primary or secondary key.
type StaticWebsite ¶
type StaticWebsite = generated.StaticWebsite
StaticWebsite - The properties that enable an account to host a static website
type StorageServiceProperties ¶
type StorageServiceProperties = generated.StorageServiceProperties
StorageServiceProperties - Storage Service Properties.
type StorageServiceStats ¶
type StorageServiceStats = generated.StorageServiceStats
StorageServiceStats - Stats for the storage service.
type UserDelegationCredential ¶
type UserDelegationCredential = exported.UserDelegationCredential
UserDelegationCredential contains an account's name and its user delegation key.
type UserDelegationKey ¶
type UserDelegationKey = generated.UserDelegationKey
UserDelegationKey contains UserDelegationKey.