cloud

package
v1.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 0 Imported by: 207

Documentation

Overview

Package cloud implements a configuration API for applications deployed to sovereign or private Azure clouds.

Azure SDK client configuration defaults are appropriate for Azure Public Cloud (sometimes referred to as "Azure Commercial" or simply "Microsoft Azure"). This package enables applications deployed to other Azure Clouds to configure clients appropriately.

This package contains predefined configuration for well-known sovereign clouds such as Azure Government and Azure China. Azure SDK clients accept this configuration via the Cloud field of azcore.ClientOptions. For example, configuring a credential and ARM client for Azure Government:

opts := azcore.ClientOptions{Cloud: cloud.AzureGovernment}
cred, err := azidentity.NewDefaultAzureCredential(
	&azidentity.DefaultAzureCredentialOptions{ClientOptions: opts},
)
handle(err)

client, err := armsubscription.NewClient(
	cred, &arm.ClientOptions{ClientOptions: opts},
)
handle(err)

Applications deployed to a private cloud such as Azure Stack create a Configuration object with appropriate values:

c := cloud.Configuration{
	ActiveDirectoryAuthorityHost: "https://...",
	Services: map[cloud.ServiceName]cloud.ServiceConfiguration{
		cloud.ResourceManager: {
			Audience: "...",
			Endpoint: "https://...",
		},
	},
}
opts := azcore.ClientOptions{Cloud: c}

cred, err := azidentity.NewDefaultAzureCredential(
	&azidentity.DefaultAzureCredentialOptions{ClientOptions: opts},
)
handle(err)

client, err := armsubscription.NewClient(
	cred, &arm.ClientOptions{ClientOptions: opts},
)
handle(err)

Index

Constants

This section is empty.

Variables

View Source
var (
	// AzureChina contains configuration for Azure China.
	AzureChina = Configuration{
		ActiveDirectoryAuthorityHost: "https://login.chinacloudapi.cn/", Services: map[ServiceName]ServiceConfiguration{},
	}
	// AzureGovernment contains configuration for Azure Government.
	AzureGovernment = Configuration{
		ActiveDirectoryAuthorityHost: "https://login.microsoftonline.us/", Services: map[ServiceName]ServiceConfiguration{},
	}
	// AzurePublic contains configuration for Azure Public Cloud.
	AzurePublic = Configuration{
		ActiveDirectoryAuthorityHost: "https://login.microsoftonline.com/", Services: map[ServiceName]ServiceConfiguration{},
	}
)

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	// ActiveDirectoryAuthorityHost is the base URL of the cloud's Azure Active Directory.
	ActiveDirectoryAuthorityHost string
	// Services contains configuration for the cloud's services.
	Services map[ServiceName]ServiceConfiguration
}

Configuration configures a cloud.

type ServiceConfiguration

type ServiceConfiguration struct {
	// Audience is the audience the client will request for its access tokens.
	Audience string
	// Endpoint is the service's base URL.
	Endpoint string
}

ServiceConfiguration configures a specific cloud service such as Azure Resource Manager.

type ServiceName

type ServiceName string

ServiceName identifies a cloud service.

const ResourceManager ServiceName = "resourceManager"

ResourceManager is a global constant identifying Azure Resource Manager.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL