How to Use the Azure SDK for Go
Use the official Azure SDK for Go modules to interact with Azure services by initializing a client with your credentials and calling service methods.
package main
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
)
func main() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatal(err)
}
client, err := azblob.NewClient("https://<account>.blob.core.windows.net", cred, nil)
if err != nil {
log.Fatal(err)
}
_, err = client.DownloadStream(context.Background(), "<container>", "<blob>", nil)
if err != nil {
log.Fatal(err)
}
}