### Install the Azure Web PubSub service client module for Go Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/messaging/azwebpubsub/README.md Use `go get` to install the package. This is the first step to start using the library. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/messaging/azwebpubsub ``` -------------------------------- ### Install Profile Builder (Bash) Source: https://github.com/azure/azure-sdk-for-go/blob/main/eng/tools/profileBuilder/README.md Installs the profileBuilder tool using 'go get -u'. This is the simplest but not the most stable installation method. ```bash go get -u github.com/Azure/azure-sdk-for-go/eng/tools/profileBuilder ``` -------------------------------- ### Install Profile Builder (Go Get -d and Go Install - Bash) Source: https://github.com/azure/azure-sdk-for-go/blob/main/eng/tools/profileBuilder/README.md Installs the profileBuilder tool by first downloading the source code with 'go get -d' and then building it with 'go install'. This method provides more control. ```bash # bash go get -d github.com/Azure/azure-sdk-for-go/eng/tools/profileBuilder cd $GOPATH/src/github.com/Azure/azure-sdk-for-go/eng/tools/profileBuilder go install ``` -------------------------------- ### Install Azure Reservations Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/reservations/armreservations/README.md Install the Azure Reservations module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armreservations/v4 ``` -------------------------------- ### Install Azure Portal Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/portal/armportal/README.md Use `go get` to install the Azure Portal module for Go. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/portal/armportal ``` -------------------------------- ### Install Azure Kubernetes Configuration Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations/README.md Use 'go get' to install the module. This command fetches and installs the specified package and its dependencies. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armfluxconfigurations ``` -------------------------------- ### Install the Azure Tables client library for Go Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/data/aztables/README.md Install the necessary package using the go get command. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/data/aztables ``` -------------------------------- ### Install azcertificates and azidentity Packages Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/security/keyvault/azcertificates/README.md Install the necessary packages for certificate management and Azure authentication using go get. ```Bash go get github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azcertificates go get github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### Install Certificate Registration Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/certificateregistration/armcertificateregistration/README.md Install the Azure Certificate Registration module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/certificateregistration/armcertificateregistration ``` -------------------------------- ### Install Azure Dell Storage Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/dell/armdellstorage/README.md Install the Azure Dell module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dell/armdellstorage ``` -------------------------------- ### Install Profile Builder (Go Get -d and Go Install - PowerShell) Source: https://github.com/azure/azure-sdk-for-go/blob/main/eng/tools/profileBuilder/README.md Installs the profileBuilder tool using PowerShell. It first downloads the source code with 'go get -d' and then builds it with 'go install'. ```powershell # PowerShell go get -d github.com/Azure/azure-sdk-for-go/eng/tools/profileBuilder cd $env:GOPATH\src\github.com\Azure/azure-sdk-for-go/eng/tools\profileBuilder go install ``` -------------------------------- ### Install Azure VoiceServices Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/voiceservices/armvoiceservices/README.md Install the Azure VoiceServices module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/voiceservices/armvoiceservices ``` -------------------------------- ### Install Azure Visual Studio Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/visualstudio/armvisualstudio/README.md Install the Azure Visual Studio module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/visualstudio/armvisualstudio ``` -------------------------------- ### Install Azure Marketplace Ordering Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/marketplaceordering/armmarketplaceordering/README.md Install the Azure Marketplace Ordering module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/marketplaceordering/armmarketplaceordering ``` -------------------------------- ### Live Test Suite Example Source: https://github.com/azure/azure-sdk-for-go/blob/main/documentation/development/testing.md Example test suite for operations, including setup for recording, client initialization, and resource group management. ```go //go:build go1.18 // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. package armchaos_test import ( "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) type OperationsTestSuite struct { suite.Suite ctx context.Context cred azcore.TokenCredential options *arm.ClientOptions armEndpoint string location string resourceGroupName string subscriptionId string } func (testsuite *OperationsTestSuite) SetupSuite() { testutil.StartRecording(testsuite.T(), pathToPackage) testsuite.ctx = context.Background() testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) testsuite.armEndpoint = "https://management.azure.com" testsuite.location = recording.GetEnvVariable("LOCATION", "eastus") testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) testsuite.Require().NoError(err) testsuite.resourceGroupName = *resourceGroup.Name } func (testsuite *OperationsTestSuite) TearDownSuite() { _, err := testutil.DeleteResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName) testsuite.Require().NoError(err) testutil.StopRecording(testsuite.T()) } func TestOperationsTestSuite(t *testing.T) { suite.Run(t, new(OperationsTestSuite)) } // Microsoft.Chaos/operations func (testsuite *OperationsTestSuite) TestOperation() { var err error // From step Operations_ListAll operationsClient, err := armchaos.NewOperationStatusesClient(testsuite.subscriptionId, testsuite.cred, nil) testsuite.Require().NoError(err) _, err = operationsClient.Get(testsuite.ctx, testsuite.location, testsuite.subscriptionId, nil) testsuite.Require().NoError(err) } ``` -------------------------------- ### Install Azure Management Partner Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/managementpartner/armmanagementpartner/README.md Install the Azure Management Partner module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementpartner/armmanagementpartner ``` -------------------------------- ### Install Event Hubs Package Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/messaging/azeventhubs/README.md Install the Azure Event Hubs client module for Go using 'go get'. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/v2 ``` -------------------------------- ### Install Azure Resources Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/resources/armdeployments/README.md Installs the Azure Resources module for Go using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeployments/v2 ``` -------------------------------- ### Install Azure Deviceregistry Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/deviceregistry/armdeviceregistry/README.md Install the Azure Deviceregistry module using go get. This command fetches and installs the specified version of the module. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceregistry/armdeviceregistry/v2 ``` -------------------------------- ### Install Azure Billing Benefits Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/billingbenefits/armbillingbenefits/README.md Install the Azure Billing Benefits module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billingbenefits/armbillingbenefits/v3 ``` -------------------------------- ### Install azquery and azidentity modules Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/monitor/azquery/README.md Install the necessary modules for Azure Monitor Query and Azure Identity using go get. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/monitor/azquery go get github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### Install Azure Trustedsigning Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/trustedsigning/armtrustedsigning/README.md Use `go get` to install the Azure Trustedsigning module for your Go project. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trustedsigning/armtrustedsigning ``` -------------------------------- ### Install Azure Cosmos DB SDK for Go Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/data/azcosmos/README.md Install the Azure Cosmos DB SDK for Go using the go get command. ```bash go get -u github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos ``` -------------------------------- ### Install Azure Queue Storage SDK for Go Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/storage/azqueue/README.md Install the Azure Queue Storage SDK for Go using go get. If using Azure Active Directory for authentication, also install the azidentity module. ```powershell go get github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/v2 ``` ```powershell go get github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### Install azlogs and azidentity modules Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/monitor/ingestion/azlogs/README.md Install the necessary modules for Azure Monitor logs ingestion and identity management using go get. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/monitor/ingestion/azlogs go get github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### Install azmetrics and azidentity modules Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/monitor/query/azmetrics/README.md Install the necessary modules for Azure Monitor metrics querying and authentication using go get. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/monitor/query/azmetrics go get github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### Install Azure Automanage and Azure Identity Packages Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/automanage/armautomanage/README.md Install the necessary Azure SDK packages for Go using the go get command. ```sh go get "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/automanage/armautomanage" go get "github.com/Azure/azure-sdk-for-go/sdk/azidentity" ``` -------------------------------- ### Install Azure Service Bus Go Package Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/messaging/azservicebus/README.md Install the Azure Service Bus client module for Go using 'go get'. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus ``` -------------------------------- ### Install Azure VMware Cloud Simple Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/README.md Install the Azure VMware Cloud Simple module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple ``` -------------------------------- ### Install Azure Bot Service Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/botservice/armbotservice/README.md Install the Azure Bot Service module using go get. This command fetches and installs the specified version of the module. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice/v2 ``` -------------------------------- ### Install Azure Blob Storage Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/storage/azblob/README.md Install the Azure Blob Storage client module for Go using go get. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob ``` -------------------------------- ### Install Azure Container Apps Module for Go Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/appcontainers/armappcontainers/README.md Use `go get` to install the Azure Container Apps module. This command fetches and installs the specified version of the SDK. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcontainers/armappcontainers/v5 ``` -------------------------------- ### Install azappconfig Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/data/azappconfig/README.md Install the azappconfig module using go get. Ensure you are using a supported Go version. ```Bash go get github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig/v2 ``` -------------------------------- ### Create utils_test.go for Live Tests Source: https://github.com/azure/azure-sdk-for-go/blob/main/documentation/development/testing.md Entry point file for live tests. Ensure 'package' and 'pathToPackage' are correctly set for your service. ```go //go:build go1.18 // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. package armchaos_test import ( "os" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" ) const ( pathToPackage = "sdk/resourcemanager/chaos/armchaos/testdata" ) func TestMain(m *testing.M) { code := run(m) os.Exit(code) } func run(m *testing.M) int { f := testutil.StartProxy(pathToPackage) defer f() return m.Run() } ``` -------------------------------- ### Install Azure File Storage SDK for Go Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/storage/azfile/README.md Use 'go get' to install the Azure File Storage SDK for Go. If using Azure Active Directory for authentication, also install the 'azidentity' module. ```Powershell go get github.com/Azure/azure-sdk-for-go/sdk/storage/azfile ``` ```Powershell go get github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### Install Azure Resources Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/resources/armdeploymentstacks/README.md Install the Azure Resources module for Go using go get. This command fetches and installs the specified version of the armdeploymentstacks package. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentstacks/v2 ``` -------------------------------- ### Install the Azure Event Grid Client Module for Go Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/messaging/eventgrid/azeventgrid/README.md Install the Azure Event Grid client module for Go using the `go get` command. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azeventgrid ``` -------------------------------- ### Install Azure CDN Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/cdn/armcdn/README.md Install the Azure Content Delivery Network module for Go using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cdn/armcdn/v3 ``` -------------------------------- ### Test Helper Method Usage Source: https://github.com/azure/azure-sdk-for-go/blob/main/documentation/development/testing.md Demonstrates how to integrate `startRecording` and `createClientForRecording` into a test function. This setup ensures recording is active before test execution. ```go func TestExample(t *testing.T) { startRecording(t) client, err := createClientForRecording(t, "myTableName", "myServiceUrl") require.NoError(t, err) ... } ``` -------------------------------- ### Install Azure Selfhelp Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/selfhelp/armselfhelp/README.md Install the Azure Selfhelp module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/selfhelp/armselfhelp/v2 ``` -------------------------------- ### Initialize Go SDK Generation Environment Source: https://github.com/azure/azure-sdk-for-go/blob/main/documentation/development/ARM/code-generation.md Run the automation initialization script to set up the Go SDK generation environment. This script also installs the generator as a global tool. ```bash cd "~/azure-sdk-for-go/eng/scripts" # navigate to the script directory ./automation_init.sh ``` -------------------------------- ### Azure Queue Storage Service Client Setup and Operations Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/storage/azqueue/README.md Demonstrates setting up a shared key credential and using the service client to perform basic queue operations: create, enqueue, dequeue, and delete. ```go // shared key credential set up cred := azqueue.NewSharedKeyCredential(accountName, accountKey) // instantiate service client serviceClient, err := azqueue.NewServiceClientWithSharedKeyCredential(account, cred, nil) // TODO: handle error // 1. create queue queueClient := serviceClient.NewQueueClient(queueName) _, err = queueClient.Create(context.TODO(), nil) // TODO: handle error // 2. enqueue message _, err = queueClient.EnqueueMessage(context.TODO(), message, nil) // TODO: handle error // 3. dequeue message _, err = queueClient.DequeueMessage(context.TODO(), nil) // TODO: handle error // 4. delete queue _, err =queueClient.Delete(context.TODO(), nil) // TODO: handle error ``` -------------------------------- ### Install Azure ProgramEnrollment Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/programenrollment/armprogramenrollment/README.md Install the Azure ProgramEnrollment module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/programenrollment/armprogramenrollment ``` -------------------------------- ### Install Azure Confluent Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/confluent/armconfluent/README.md Install the Azure Confluent module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent/v2 ``` -------------------------------- ### Create Certificate using keyvault module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/security/keyvault/azcertificates/MIGRATION.md Demonstrates creating a certificate using the older `keyvault` module. Requires setting up an `Authorizer` and passing the Key Vault URL with each method call. ```go import ( "context" "fmt" "github.com/Azure/azure-sdk-for-go/profiles/latest/keyvault/keyvault" kvauth "github.com/Azure/azure-sdk-for-go/services/keyvault/auth" ) func main() { vaultURL := "https://.vault.azure.net" authorizer, err := kvauth.NewAuthorizerFromEnvironment() if err != nil { // TODO: handle error } basicClient := keyvault.New() basicClient.Authorizer = authorizer fmt.Println("\ncreating certificate in keyvault:") issuerName := "self" subject := "CN=DefaultPolicy" createParams := keyvault.CertificateCreateParameters{ CertificatePolicy: &keyvault.CertificatePolicy{ IssuerParameters: &keyvault.IssuerParameters{Name: &issuerName}, X509CertificateProperties: &keyvault.X509CertificateProperties{Subject: &subject}, } } resp, err := basicClient.CreateCertificate(context.TODO(), vaultURL, "", createParams) if err != nil { // TODO: handle error } fmt.Println("added/updated: " + *resp.ID) } ``` -------------------------------- ### Install Azure Datadog Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/datadog/armdatadog/README.md Install the Azure Datadog module using go get. This command fetches the specified version of the SDK. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/datadog/armdatadog/v2 ``` -------------------------------- ### Install Azure Storsimple8000series Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/storsimple8000series/armstorsimple8000series/README.md Use 'go get' to install the Azure Storsimple8000series module. This command fetches and installs the specified package and its dependencies. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storsimple8000series/armstorsimple8000series ``` -------------------------------- ### Navigate, Build, and Test Go Modules Source: https://github.com/azure/azure-sdk-for-go/blob/main/AGENTS.md Commands to navigate to an SDK module, build it, and run tests. Ensure you are in the correct module directory before executing. ```bash # Navigate to the SDK module you want to work with cd sdk/azcore # or any other module # Build the module go build ./... # Run tests go test ./... ``` -------------------------------- ### Install Azure Orbital Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/orbital/armorbital/README.md Install the Azure Orbital module using go get. This command fetches and installs the specified version of the module. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/orbital/armorbital/v2 ``` -------------------------------- ### Install Azure Maps Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/maps/armmaps/README.md Install the Azure Maps module using go get. This command fetches and installs the specified version of the module. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maps/armmaps/v2 ``` -------------------------------- ### Entity Management with admin.Client Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/messaging/azservicebus/migrationguide.md Shows how to create a new admin client using a connection string and then use it to create a queue with default or configured properties. ```go // note: import "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus/admin" adminClient, err := admin.NewClientFromConnectionString(connectionString, nil) // create a queue with default properties resp, err := adminClient.CreateQueue(context.TODO(), "queue-name", nil) // or create a queue and configure some properties ``` -------------------------------- ### Install Event Grid System Events Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/messaging/eventgrid/azsystemevents/README.md Install the Azure Event Grid system events module for Go using the go get command. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/azsystemevents ``` -------------------------------- ### Install Azure Elastic Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/elastic/armelastic/README.md Install the Azure Elastic module using go get. This command fetches and installs the specified version of the module. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic/v3 ``` -------------------------------- ### Start and Stop Test Recording Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/internal/recording/README.md Use `recording.Start` to begin a test recording and `defer recording.Stop` to ensure proper cleanup. This is essential for managing test environments. ```go func TestSomething(t *testing.T) { err := recording.Start(t, recordingDirectory, nil) defer recording.Stop(t, recordingDirectory, nil) // Continue test } ``` -------------------------------- ### Install the Azure Database for PostgreSQL module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/postgresql/armpostgresql/README.md Use `go get` to install the necessary module for managing Azure Database for PostgreSQL resources. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresql ``` -------------------------------- ### Initialize OpenAI Client (v1) Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/ai/azopenai/MIGRATION.md Use `openai.NewClient` with `option.WithAPIKey` for initializing the client for the OpenAI service. ```go key := os.Getenv("OPENAI_API_KEY") client := openai.NewClient( option.WithAPIKey(key), ) ``` -------------------------------- ### Install Azure Disconnectedoperations Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/disconnectedoperations/armdisconnectedoperations/README.md Install the Azure Disconnectedoperations module using go get. This command fetches and installs the specified package and its dependencies. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/disconnectedoperations/armdisconnectedoperations ``` -------------------------------- ### Install azopenai and azidentity modules Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/ai/azopenai/README.md Install the `azopenai` and `azidentity` modules using `go get`. The `azidentity` module is optional but recommended for Azure Active Directory authentication. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai # optional go get github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### Install Azure Chaos Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/chaos/armchaos/README.md Install the Azure Chaos module using go get. This command fetches and installs the specified version of the package. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2 ``` -------------------------------- ### Install Azure Commerce Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/commerce/armcommerce/README.md Install the Azure Commerce module using go get. This command fetches and installs the specified package and its dependencies. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/commerce/armcommerce ``` -------------------------------- ### Install azbatch and azidentity modules Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/batch/azbatch/README.md Install the necessary Azure SDK for Go modules for Batch and identity management. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/batch/azbatch go get github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### Install Azure Authorization Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/authorization/armauthorization/README.md Install the Azure Authorization module using go get. This command fetches and installs the specified package and its dependencies. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v3 ``` -------------------------------- ### Install Azure Purview Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/purview/armpurview/README.md Install the Azure Purview module for Go using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/purview/armpurview/v2 ``` -------------------------------- ### Install azadmin and azidentity Packages Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/security/keyvault/azadmin/README.md Install the necessary Azure SDK packages for Go using the `go get` command. `azidentity` is required for Azure Active Directory authentication. ```go go get github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azadmin go get github.com/Azure/azure-sdk-for-go/sdk/azidentity ``` -------------------------------- ### Install Azure Consumption Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/consumption/armconsumption/README.md Install the Azure Consumption module for Go using go get. This command fetches and installs the specified version of the package. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2 ``` -------------------------------- ### Install Azure Compute Bulkactions Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/computebulkactions/armcomputebulkactions/README.md Install the Azure Compute Bulkactions module using go get. This command fetches and installs the specified package. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/computebulkactions/armcomputebulkactions ``` -------------------------------- ### Create Instances Client Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/weightsandbiases/armweightsandbiases/README.md Instantiate a client for managing Weights and Biases instances using the client factory. ```go client := clientFactory.NewInstancesClient() ``` -------------------------------- ### Install Azure Managed Application Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/solutions/armmanagedapplications/README.md Install the Azure Managed Application module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/solutions/armmanagedapplications/v2 ``` -------------------------------- ### Install Azure File Shares Package Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/fileshares/armfileshares/README.md Install the Azure File Shares management client library for Go. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fileshares/armfileshares ``` -------------------------------- ### Install Azure Cache for Redis Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/redis/armredis/README.md Install the Azure Cache for Redis module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis/v4 ``` -------------------------------- ### Install Azure Database for MySQL Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/mysql/armmysql/README.md Install the Azure Database for MySQL module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql ``` -------------------------------- ### Previous Version Authentication Client Initialization Source: https://github.com/azure/azure-sdk-for-go/blob/main/documentation/development/ARM/MIGRATION_GUIDE.md Example of initializing an authorizer and a resource client using the older Azure SDK for Go management libraries. ```go authorizer, err := adal.NewServicePrincipalToken(oAuthToken, "", "", endpoint) client := resources.NewGroupsClient("") client.Authorizer = authorizer ``` -------------------------------- ### Install Azure Health Bot Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/healthbot/armhealthbot/README.md Install the Azure Health Bot module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/healthbot/armhealthbot/v2 ``` -------------------------------- ### Install Azure Graphservices Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/graphservices/armgraphservices/README.md Use `go get` to install the Azure Graphservices module for your Go project. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/graphservices/armgraphservices ``` -------------------------------- ### Install Azure Cosmos DB Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/cosmos/armcosmos/README.md Install the Azure Cosmos DB module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v4 ``` -------------------------------- ### Install Azure Container Registry Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/containerregistry/armcontainerregistry/README.md Install the Azure Container Registry module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry/v3 ``` -------------------------------- ### Install Event Grid Namespaces Client Module for Go Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/messaging/eventgrid/aznamespaces/README.md Install the Azure Event Grid Namespaces client module for Go using the go get command. ```bash go get github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/aznamespaces ``` -------------------------------- ### Install Azure Hybrid Data Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/azuredata/armazuredata/README.md Install the Azure Hybrid Data module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuredata/armazuredata ``` -------------------------------- ### Install Azure Domain Registration Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/domainregistration/armdomainregistration/README.md Installs the Azure Domain Registration module using Go modules. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/domainregistration/armdomainregistration ``` -------------------------------- ### Install Azure Alerts Management Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/alertsmanagement/armalertsmanagement/README.md Install the Azure Alerts Management module using go get. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement ``` -------------------------------- ### Initialize Compute Client (Latest Version) Source: https://github.com/azure/azure-sdk-for-go/blob/main/documentation/development/ARM/MIGRATION_GUIDE.md Initialize a Virtual Machines client in the latest SDK version. For custom endpoints, set them via ClientOptions. ```go import "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute" ``` ```go client, err := armcompute.NewVirtualMachinesClient("", credential, nil) ``` -------------------------------- ### Install Azure Compute Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/documentation/development/ARM/new-version-quickstart.md Use 'go get' to install the Azure Compute module for resource management. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute ``` -------------------------------- ### Install Azure Directory and Database Infrastructure Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/m365securityandcompliance/armm365securityandcompliance/README.md Install the Azure Directory and Database Infrastructure module using go get. This command fetches the package and its dependencies. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/m365securityandcompliance/armm365securityandcompliance ``` -------------------------------- ### Install Azure Virtual Desktop Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/desktopvirtualization/armdesktopvirtualization/README.md Installs the Azure Virtual Desktop module for Go using go modules. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/desktopvirtualization/armdesktopvirtualization/v2 ``` -------------------------------- ### Install Azure Serial Console Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/serialconsole/armserialconsole/README.md Install the Azure Serial Console module using go get. This command fetches and installs the specified version of the module. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/serialconsole/armserialconsole/v2 ``` -------------------------------- ### Install Azure Service Fabric Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/servicefabric/armservicefabric/README.md Install the Azure Service Fabric module using go get. This command fetches and installs the specified version of the module. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v3 ``` -------------------------------- ### Install Azure Service Groups Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/servicegroups/armservicegroups/README.md Install the Azure Service Groups module using go get. This command fetches and installs the specified package and its dependencies. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicegroups/armservicegroups ``` -------------------------------- ### Create Backup Instances Client Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/dataprotection/armdataprotection/README.md Creates a client for managing backup instances using the client factory. ```go client := clientFactory.NewBackupInstancesClient() ``` -------------------------------- ### Install Azure Network Cloud Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/networkcloud/armnetworkcloud/README.md Install the Azure Network Cloud module using go get. This command fetches and installs the latest version of the package. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkcloud/armnetworkcloud ``` -------------------------------- ### Install Azure Healthcare APIs Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/healthcareapis/armhealthcareapis/README.md Install the Azure Healthcare APIs module using go get. This command fetches and installs the specified version of the module. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/healthcareapis/armhealthcareapis/v3 ``` -------------------------------- ### Install Azure Kubernetes Configuration Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/README.md Install the Azure Kubernetes Configuration module using go get. This command fetches and installs the specified version of the module. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/v2 ``` -------------------------------- ### Install Generator Tool for Go SDK Source: https://github.com/azure/azure-sdk-for-go/blob/main/documentation/development/ARM/go-mgmt-sdk-release-guideline.md Installs the Azure SDK for Go generator tool. If the initial command fails, use the alternative command. ```bash go get github.com/Azure/azure-sdk-for-go/tools/generator ``` ```bash cd eng/tools/generator && go install ``` -------------------------------- ### Querying Metrics with armmonitor Client Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/monitor/query/MIGRATION.md This snippet demonstrates how to create a `MetricsClient` and execute a metrics query using the `armmonitor` package. Ensure you have the necessary credentials and resource ID. The `ListOptions` allow for detailed configuration of the query parameters. ```go import ( "context" "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/resourcemanager/monitor/armmonitor" ) func main() { // create the client cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { //TODO: handle error } client, err := armmonitor.NewMetricsClient("", cred, nil) if err != nil { //TODO: handle error } // execute the query res, err := client.List(context.Background(), "", &armmonitor.MetricsClientListOptions{ Timespan: to.Ptr("2021-04-20T09:00:00.000Z/2021-04-20T14:00:00.000Z"), Interval: to.Ptr("PT6H"), Metricnames: to.Ptr("BlobCount,BlobCapacity"), Aggregation: to.Ptr("average,minimum,maximum"), Top: to.Ptr[int32](5), Orderby: to.Ptr("average asc"), Filter: to.Ptr("Tier eq '*'"), ResultType: nil, Metricnamespace: to.Ptr("Microsoft.Storage/storageAccounts/blobServices"), AutoAdjustTimegrain: to.Ptr(true), ValidateDimensions: to.Ptr(false), }) if err != nil { //TODO: handle partial error } _ = res } ``` -------------------------------- ### Install Azure Kubernetes Configuration Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/kubernetesconfiguration/armextensions/README.md Use `go get` to install the Azure Kubernetes Configuration module for Go. This command fetches and installs the package and its dependencies. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armextensions ``` -------------------------------- ### Initialize Global Upload Test Setup Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/internal/perf/README.md Sets up global resources for upload performance tests, including creating a container. Requires the AZURE_STORAGE_CONNECTION_STRING environment variable. ```go type uploadTestGlobal struct { perf.PerfTestOptions containerName string blobName string globalContainerClient azblob.ContainerClient } // NewUploadTest is called once per process func NewUploadTest(ctx context.Context, options perf.PerfTestOptions) (perf.GlobalPerfTest, error) { u := &uploadTestGlobal{ PerfTestOptions: options, containerName: "uploadcontainer", blobName: "uploadblob", } connStr, ok := os.LookupEnv("AZURE_STORAGE_CONNECTION_STRING") if !ok { return nil, fmt.Errorf("the environment variable 'AZURE_STORAGE_CONNECTION_STRING' could not be found") } containerClient, err := azblob.NewContainerClientFromConnectionString(connStr, u.containerName, nil) if err != nil { return nil, err } u.globalContainerClient = containerClient _, err = u.globalContainerClient.Create(context.Background(), nil) if err != nil { return nil, err } return u, nil } ``` -------------------------------- ### Install Azure Dedicated HSM Module Source: https://github.com/azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/hardwaresecuritymodules/armhardwaresecuritymodules/README.md Install the Azure Dedicated HSM module using go get. This command fetches and installs the specified version of the module. ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hardwaresecuritymodules/armhardwaresecuritymodules/v3 ```