Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 1.88 KB

File metadata and controls

46 lines (33 loc) · 1.88 KB
title include file
description include file
services storage
author pauljewellmsft
ms.service azure-blob-storage
ms.topic include
ms.date 05/22/2024
ms.author pauljewell
ms.custom include file

If you don't have an existing project, this section shows how to set up a project to work with the Azure Blob Storage client module for Go. The steps include module installation, adding import paths, and creating an authorized client object. For details, see Get started with Azure Blob Storage and Go.

Install modules

Install the azblob module using the following command:

go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob

To authenticate with Microsoft Entra ID (recommended), install the azidentity module using the following command:

go get github.com/Azure/azure-sdk-for-go/sdk/azidentity

Add import paths

In your code file, add the following import paths:

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

These import paths represent the minimum needed to get started. Some code examples in this article might require additional import paths. For specific details and example usage, see Code samples.

Create a client object

To connect an app to Blob Storage, create a client object using azblob.NewClient. The following example shows how to create a client object using DefaultAzureCredential for authorization:

:::code language="go" source="~/blob-devguide-go/cmd/client-auth/client_auth.go" id="snippet_get_service_client_DAC":::