Azure SDK for Go

repository·main·Indexed 23 days ago

https://github.com/azure/azure-sdk-for-go

Libraries for interacting with Azure services, featuring client modules for resource consumption and management modules for service configuration. The SDK is generated using the TypeSpec code generator and includes tools for MCP server integration, X509 certificate generation, and test-proxy asset migration.

Tokens
302.2K
Snippets
1.3K
Records
2.1K
Agent score
83%

What's inside azure-sdk-for-go

  1. Overview of the Generator tool

    main

    The generator is a command-line tool used to manage the development lifecycle of the github.com/Azure/azure-sdk-for-go repository. It automates tasks related to package generation, versioning, and release management.

    Key capabilities include:

    • Build: Compiling and validating Go packages.
    • Changelog: Managing changelog content.
    • Version: Calculating and updating version numbers.
    • Metadata: Creating ci.yml and README.md files.
    • Environment: Validating development prerequisites.
    • Generate: Creating SDK packages from TypeSpec specifications.
    • Issue Management: Parsing GitHub release request issues.
    • Release Generation: Creating releases from TypeSpec or Swagger.
    • Automation: Batch processing for CI/CD.
    • Refresh: Regenerating existing packages.
    • Templates: Scaffolding new packages for onboard services.
  2. Overview of Azure Compute Schedule operations

    main

    Microsoft Azure Compute Schedule allows scheduling one-off operations on virtual machines, including Start, Deallocate, and Hibernate.

    Operations are categorized into two types:

    • Submit Type Operations: Can be scheduled for a future date (up to 14 days ahead).
    • Execute Type Operations: Performed on virtual machines immediately.

    Additionally, the module provides endpoints to:

    • Get operation status on virtual machines.
    • Cancel scheduled operations.
    • Retrieve errors that occurred during operations.
  3. Use the Azure Identity Cache Module for Go

    main

    The azidentity/cache module provides a cross-platform persistent token cache for azidentity credentials. This allows credentials to persist across different application runs, reducing the frequency of interactive logins or repeated token requests.

    To implement persistent caching, you must configure your azidentity credentials with a cache implementation provided by this module. For detailed implementation details, refer to the official token caching documentation.

  4. Understanding the azwebpubsub Go SDK structure

    main

    The azwebpubsub package is the Go implementation of the Azure Web PubSub data-plane client. It is generated from the Azure REST API specification and follows standard Azure SDK for Go patterns.

    Key characteristics of this SDK include:

    • Module Path: github.com/Azure/azure-sdk-for-go/sdk/messaging/azwebpubsub
    • Permission Naming: To avoid redundancy with the package name, the enum WebPubSubPermission is exported as Permission.
    • Client Structure: The Client struct manages the connection to the service using an internal azcore.Client, an endpoint, and an authentication key.
  5. What is the Azure Profile Module for Go

    main
    The Azure Profile Module provides a way to virtualize API versions for services. This is specifically designed for environments like Azure Stack, where the service environment may be less consistent than the public cloud. This specific module targets the hybrid-2020-09-01 profile.
  6. Understand the Metrics Query Client API structure

    main

    The Metrics Query Client provides specialized methods for retrieving metric definitions, namespaces, and resource metrics. The following operations are exposed:

    Renamed Operations:

    • Metrics_List is available as Metrics_QueryResource.
    • MetricDefinitions_List is available as Metrics_ListDefinitions.
    • MetricNamespaces_List is available as Metrics_ListNamespaces.

    Renamed Model Fields:

    • Metric.timeseries is renamed to TimeSeries.
    • TimeSeriesElement.metadatavalues is renamed to MetadataValues.
    • Response.resourceregion is renamed to ResourceRegion.

    Renamed Parameters:

    • MetricNamespaceParameter is renamed to MetricNamespace.
    • MetricNamesParameter is renamed to MetricNames.
    • OrderByParameter is renamed to OrderBy.
    • RollUpByParameter is renamed to RollUpBy.

    Aggregation Type:

    • The Aggregation field in MetricsClientQueryResourceOptions is a slice of *AggregationType ([]*AggregationType) rather than a single string.
  7. Authenticate the Azure Event Grid client

    main

    The azeventgrid publisher client supports three authentication methods:

    1. TokenCredential: Standard Azure identity authentication.
    2. Shared Key: Authentication using a shared key credential.
    3. Shared Access Signature (SAS): Authentication using a SAS token.

    Note: This client is specifically for publishing events to Event Grid topics. It does NOT work with Event Grid namespaces. For namespace support, use the aznamespaces module.

  8. Update Authentication to use azidentity

    main

    In track2 (sdk/resourcemanager/**/arm**), authentication is handled via azidentity and passed to a ClientFactory. This replaces the autorest.Authorizer used in track1.

    import "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
    import "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
    
    // Create credential
    credential, err := azidentity.NewClientSecretCredential("<TenantId>", "<ClientId>", "<ClientSecret>", nil)
    
    // Create client factory
    clientFactory, err := armresources.NewClientFactory(<subscription ID>, credential, &options)
    if err != nil {
        log.Fatal(err)
    }
    
    // Get specific client
    client := clientFactory.NewResourceGroupsClient()