The possible keys in the Values map.
const ( SubscriptionID = "AZURE_SUBSCRIPTION_ID" TenantID = "AZURE_TENANT_ID" AuxiliaryTenantIDs = "AZURE_AUXILIARY_TENANT_IDS" ClientID = "AZURE_CLIENT_ID" ClientSecret = "AZURE_CLIENT_SECRET" CertificatePath = "AZURE_CERTIFICATE_PATH" CertificatePassword = "AZURE_CERTIFICATE_PASSWORD" Username = "AZURE_USERNAME" Password = "AZURE_PASSWORD" EnvironmentName = "AZURE_ENVIRONMENT" Resource = "AZURE_AD_RESOURCE" ActiveDirectoryEndpoint = "ActiveDirectoryEndpoint" ResourceManagerEndpoint = "ResourceManagerEndpoint" GraphResourceID = "GraphResourceID" SQLManagementEndpoint = "SQLManagementEndpoint" GalleryEndpoint = "GalleryEndpoint" ManagementEndpoint = "ManagementEndpoint" )
func NewAuthorizerFromCLI() (autorest.Authorizer, error)
NewAuthorizerFromCLI creates an Authorizer configured from Azure CLI 2.0 for local development scenarios.
func NewAuthorizerFromCLIWithResource(resource string) (autorest.Authorizer, error)
NewAuthorizerFromCLIWithResource creates an Authorizer configured from Azure CLI 2.0 for local development scenarios.
func NewAuthorizerFromEnvironment() (autorest.Authorizer, error)
NewAuthorizerFromEnvironment creates an Authorizer configured from environment variables in the order: 1. Client credentials 2. Client certificate 3. Username password 4. MSI
func NewAuthorizerFromEnvironmentWithResource(resource string) (autorest.Authorizer, error)
NewAuthorizerFromEnvironmentWithResource creates an Authorizer configured from environment variables in the order: 1. Client credentials 2. Client certificate 3. Username password 4. MSI
func NewAuthorizerFromFile(resourceBaseURI string) (autorest.Authorizer, error)
NewAuthorizerFromFile creates an Authorizer configured from a configuration file in the following order. 1. Client credentials 2. Client certificate The path to the configuration file must be specified in the AZURE_AUTH_LOCATION environment variable. resourceBaseURI - used to determine the resource type
func NewAuthorizerFromFileWithResource(resource string) (autorest.Authorizer, error)
NewAuthorizerFromFileWithResource creates an Authorizer configured from a configuration file in the following order. 1. Client credentials 2. Client certificate The path to the configuration file must be specified in the AZURE_AUTH_LOCATION environment variable.
AuthorizerConfig provides an authorizer from the configuration provided.
type AuthorizerConfig interface { Authorizer() (autorest.Authorizer, error) }
ClientCertificateConfig provides the options to get a bearer authorizer from a client certificate.
type ClientCertificateConfig struct { ClientID string CertificatePath string CertificatePassword string TenantID string AuxTenants []string AADEndpoint string Resource string }
func NewClientCertificateConfig(certificatePath string, certificatePassword string, clientID string, tenantID string) ClientCertificateConfig
NewClientCertificateConfig creates a ClientCertificateConfig object configured to obtain an Authorizer through client certificate. Defaults to Public Cloud and Resource Manager Endpoint.
func (ccc ClientCertificateConfig) Authorizer() (autorest.Authorizer, error)
Authorizer gets an authorizer object from client certificate.
func (ccc ClientCertificateConfig) MultiTenantServicePrincipalToken() (*adal.MultiTenantServicePrincipalToken, error)
MultiTenantServicePrincipalToken creates a MultiTenantServicePrincipalToken from client certificate.
func (ccc ClientCertificateConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)
ServicePrincipalToken creates a ServicePrincipalToken from client certificate.
ClientCredentialsConfig provides the options to get a bearer authorizer from client credentials.
type ClientCredentialsConfig struct { ClientID string ClientSecret string TenantID string AuxTenants []string AADEndpoint string Resource string }
func NewClientCredentialsConfig(clientID string, clientSecret string, tenantID string) ClientCredentialsConfig
NewClientCredentialsConfig creates an AuthorizerConfig object configured to obtain an Authorizer through Client Credentials. Defaults to Public Cloud and Resource Manager Endpoint.
func (ccc ClientCredentialsConfig) Authorizer() (autorest.Authorizer, error)
Authorizer gets the authorizer from client credentials.
func (ccc ClientCredentialsConfig) MultiTenantServicePrincipalToken() (*adal.MultiTenantServicePrincipalToken, error)
MultiTenantServicePrincipalToken creates a MultiTenantServicePrincipalToken from client credentials.
func (ccc ClientCredentialsConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)
ServicePrincipalToken creates a ServicePrincipalToken from client credentials.
DeviceFlowConfig provides the options to get a bearer authorizer using device flow authentication.
type DeviceFlowConfig struct { ClientID string TenantID string AADEndpoint string Resource string }
func NewDeviceFlowConfig(clientID string, tenantID string) DeviceFlowConfig
NewDeviceFlowConfig creates a DeviceFlowConfig object configured to obtain an Authorizer through device flow. Defaults to Public Cloud and Resource Manager Endpoint.
func (dfc DeviceFlowConfig) Authorizer() (autorest.Authorizer, error)
Authorizer gets the authorizer from device flow.
func (dfc DeviceFlowConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)
ServicePrincipalToken gets the service principal token from device flow.
EnvironmentSettings contains the available authentication settings.
type EnvironmentSettings struct { Values map[string]string Environment azure.Environment }
func GetSettingsFromEnvironment() (s EnvironmentSettings, err error)
GetSettingsFromEnvironment returns the available authentication settings from the environment.
func (settings EnvironmentSettings) GetAuthorizer() (autorest.Authorizer, error)
GetAuthorizer creates an Authorizer configured from environment variables in the order: 1. Client credentials 2. Client certificate 3. Username password 4. MSI
func (settings EnvironmentSettings) GetClientCertificate() (ClientCertificateConfig, error)
GetClientCertificate creates a config object from the available certificate credentials. An error is returned if no certificate credentials are available.
func (settings EnvironmentSettings) GetClientCredentials() (ClientCredentialsConfig, error)
GetClientCredentials creates a config object from the available client credentials. An error is returned if no client credentials are available.
func (settings EnvironmentSettings) GetDeviceFlow() DeviceFlowConfig
GetDeviceFlow creates a device-flow config object from the available client and tenant IDs.
func (settings EnvironmentSettings) GetMSI() MSIConfig
GetMSI creates a MSI config object from the available client ID.
func (settings EnvironmentSettings) GetSubscriptionID() string
GetSubscriptionID returns the available subscription ID or an empty string.
func (settings EnvironmentSettings) GetUsernamePassword() (UsernamePasswordConfig, error)
GetUsernamePassword creates a config object from the available username/password credentials. An error is returned if no username/password credentials are available.
FileSettings contains the available authentication settings.
type FileSettings struct { Values map[string]string }
func GetSettingsFromFile() (FileSettings, error)
GetSettingsFromFile returns the available authentication settings from an Azure CLI authentication file.
func (settings FileSettings) ClientCertificateAuthorizer(baseURI string) (autorest.Authorizer, error)
ClientCertificateAuthorizer creates an authorizer from the available certificate credentials.
func (settings FileSettings) ClientCertificateAuthorizerWithResource(resource string) (autorest.Authorizer, error)
ClientCertificateAuthorizerWithResource creates an authorizer from the available certificate credentials and the specified resource.
func (settings FileSettings) ClientCredentialsAuthorizer(baseURI string) (autorest.Authorizer, error)
ClientCredentialsAuthorizer creates an authorizer from the available client credentials.
func (settings FileSettings) ClientCredentialsAuthorizerWithResource(resource string) (autorest.Authorizer, error)
ClientCredentialsAuthorizerWithResource creates an authorizer from the available client credentials and the specified resource.
func (settings FileSettings) GetAuthorizer(resourceBaseURI string) (autorest.Authorizer, error)
GetAuthorizer create an Authorizer in the following order. 1. Client credentials 2. Client certificate resourceBaseURI - used to determine the resource type
func (settings FileSettings) GetSubscriptionID() string
GetSubscriptionID returns the available subscription ID or an empty string.
func (settings FileSettings) ServicePrincipalTokenFromClientCertificate(baseURI string) (*adal.ServicePrincipalToken, error)
ServicePrincipalTokenFromClientCertificate creates a ServicePrincipalToken from the available certificate credentials.
func (settings FileSettings) ServicePrincipalTokenFromClientCertificateWithResource(resource string) (*adal.ServicePrincipalToken, error)
ServicePrincipalTokenFromClientCertificateWithResource creates a ServicePrincipalToken from the available certificate credentials.
func (settings FileSettings) ServicePrincipalTokenFromClientCredentials(baseURI string) (*adal.ServicePrincipalToken, error)
ServicePrincipalTokenFromClientCredentials creates a ServicePrincipalToken from the available client credentials.
func (settings FileSettings) ServicePrincipalTokenFromClientCredentialsWithResource(resource string) (*adal.ServicePrincipalToken, error)
ServicePrincipalTokenFromClientCredentialsWithResource creates a ServicePrincipalToken from the available client credentials and the specified resource.
MSIConfig provides the options to get a bearer authorizer through MSI.
type MSIConfig struct { Resource string ClientID string }
func NewMSIConfig() MSIConfig
NewMSIConfig creates an MSIConfig object configured to obtain an Authorizer through MSI.
func (mc MSIConfig) Authorizer() (autorest.Authorizer, error)
Authorizer gets the authorizer from MSI.
func (mc MSIConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)
ServicePrincipalToken creates a ServicePrincipalToken from MSI.
UsernamePasswordConfig provides the options to get a bearer authorizer from a username and a password.
type UsernamePasswordConfig struct { ClientID string Username string Password string TenantID string AADEndpoint string Resource string }
func NewUsernamePasswordConfig(username string, password string, clientID string, tenantID string) UsernamePasswordConfig
NewUsernamePasswordConfig creates an UsernamePasswordConfig object configured to obtain an Authorizer through username and password. Defaults to Public Cloud and Resource Manager Endpoint.
func (ups UsernamePasswordConfig) Authorizer() (autorest.Authorizer, error)
Authorizer gets the authorizer from a username and a password.
func (ups UsernamePasswordConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)
ServicePrincipalToken creates a ServicePrincipalToken from username and password.