Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit fc2a370

Browse files
author
Stephen Tramer
committed
Cleanup based on acrolynx feedback.
1 parent a5f8d12 commit fc2a370

11 files changed

+85
-64
lines changed

azure-go-sdk-conceptual/azure-sdk-go-auth-aad-samples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Selected samples for working with Azure Active Directory (AAD) and
44
author: sptramer
55
ms.author: sttramer
66
manager: carmonm
7-
ms.date: 03/21/2018
7+
ms.date: 09/05/2018
88
ms.topic: sample
99
ms.prod: azure
1010
ms.technology: azure-sdk-go
@@ -13,7 +13,7 @@ ms.devlang: go
1313
---
1414
# Azure SDK for Go samples for authentication and AAD
1515

16-
The following table links to selected samples of Go source code that you can use to authenticate with the Azure SDK for Go and work with Azure Active Directory (AAD) services.
16+
The following table links to selected samples that demonstrate authentication and use of Azure Active Directory from the Azure SDK for Go.
1717

1818
All samples for the Azure SDK for Go are available on [GitHub](https://github.com/Azure-Samples/azure-sdk-for-go-samples).
1919

azure-go-sdk-conceptual/azure-sdk-go-authorization.md

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: azure
55
author: sptramer
66
ms.author: sttramer
77
manager: carmonm
8-
ms.date: 04/03/2018
8+
ms.date: 09/05/2018
99
ms.topic: conceptual
1010
ms.prod: azure
1111
ms.technology: azure-sdk-go
@@ -15,19 +15,19 @@ ms.component: authentication
1515
---
1616
# Authentication methods in the Azure SDK for Go
1717

18-
The Azure SDK for Go offers a variety of authentication types and methods that your application can use. Supported authentication methods range from pulling information from environment variables to interactive web-based authentication. This article introduces you to the available types of authentication in the SDK, and the methods for using them. You'll also learn best practices for selecting which authentication type is right for your application.
18+
The Azure SDK for Go offers multiple ways to authenticate with Azure. These authentication _types_ are invoked through different authentication _methods_. This article covers the available types, methods, and how to choose which are best for your application.
1919

2020
## Available authentication types and methods
2121

22-
The Azure SDK for Go offers several different types of authentication, using different credentials sets. Each of these authentication types are available through different authentication methods, which are how the SDK takes these credentials as input. The following table describes the available types of authentication and situations in which they're recommended for use by your application.
22+
The Azure SDK for Go offers several different types of authentication, using different credentials sets. Each authentication type is available through different authentication methods, which are how the SDK takes these credentials as input. The following table describes the available types of authentication and situations in which they're recommended for use by your application.
2323

2424
| Authentication type | Recommended when... |
2525
|---------------------|---------------------|
2626
| Certificate-based authentication | You have an X509 certificate that was configured for an Azure Active Directory (AAD) user or service principal. To learn more, see [Get started with certificate-based authentication in Azure Active Directory]. |
2727
| Client credentials | You have a configured service principal that is set up for this application or a class of applications it belongs to. To learn more, see [Create a service principal with Azure CLI]. |
2828
| Managed Service Identity (MSI) | Your application is running on an Azure resource that has been configured with Managed Service Identity (MSI). To learn more, see [Managed Service Identity (MSI) for Azure resources]. |
29-
| Device token | Your application is meant to be used interactively __only__ and will have a variety of users, potentially from multiple AAD tenants. Users have access to a web browser to sign in. For more information, see [Use device token authentication](#use-device-token-authentication).|
30-
| Username/password | You have an interactive application that cannot use any other authentication method. Your users do not have multi-factor authentication enabled for their AAD sign in. |
29+
| Device token | Your application is meant to be used interactively __only__. Users may have multi-factor authentication enabled. Users have access to a web browser to sign in. For more information, see [Use device token authentication](#use-device-token-authentication).|
30+
| Username/password | You have an interactive application that can't use any other authentication method. Your users don't have multi-factor authentication enabled for their AAD sign-in. |
3131

3232
> [!IMPORTANT]
3333
> If you use an authentication type other than client credentials, your application must be registered in Azure Active Directory. To learn how,
@@ -40,7 +40,12 @@ The Azure SDK for Go offers several different types of authentication, using dif
4040
[Create a service principal with Azure CLI]: /cli/azure/create-an-azure-service-principal-azure-cli
4141
[Managed Service Identity (MSI) for Azure resources]: /azure/active-directory/managed-service-identity/overview
4242

43-
These authentication types are available through different methods. [_Environment-based authentication_](#use-environment-based-authentication) reads credentials directly from the program's environment. [_File-based authentication_](#use-file-based-authentication) loads a file containing service principal credentials. [_Client-based authentication_](#use-an-authentication-client) uses an object in Go code and makes you responsible for providing the credentials during program execution. Finally, [_Device token authentication_](#use-device-token-authentication) requires users to sign in interactively through a web browser with a token, and cannot be used with environment- or file-based authentication.
43+
These authentication types are available through different methods.
44+
45+
* [_Environment-based authentication_](#use-environment-based-authentication) reads credentials directly from the program's environment.
46+
* [_File-based authentication_](#use-file-based-authentication) loads a file containing service principal credentials.
47+
* [_Client-based authentication_](#use-an-authentication-client) uses an object in code and makes you responsible for providing the credentials during program execution.
48+
* [_Device token authentication_](#use-device-token-authentication) requires users to sign in interactively through a web browser with a token.
4449

4550
All authentication functions and types are available in the `github.com/Azure/go-autorest/autorest/azure/auth` package.
4651

@@ -49,9 +54,17 @@ All authentication functions and types are available in the `github.com/Azure/go
4954
5055
## Use environment-based authentication
5156

52-
If you're running your application in a tightly controlled environment such as in a container, environment-based authentication is a natural choice. You configure the shell environment before running your application and the Go SDK reads these environment variables at runtime to authenticate with Azure.
57+
If you're running your application in a controlled setting, environment-based authentication is a natural choice. With this authentication method, you configure the shell environment before running your application. At runtime, the Go SDK reads these environment variables to authenticate with Azure.
58+
59+
Environment-based authentication has support for all authentication methods except device tokens, evaluated in the following order:
5360

54-
Environment-based authentication has support for all authentication methods except device tokens, evaluated in the following order: Client credentials, certificates, username/password, and Managed Service Identity (MSI). If a required environment variable is unset or the SDK gets a refusal from the authentication service, the next authentication type is tried. If the SDK cannot authenticate from the environment, it returns an error.
61+
* Client credentials
62+
* X509 certificates
63+
* Username/password
64+
* Managed Service Identity (MSI)
65+
66+
If an authentication type has unset values or is refused, the SDK automatically tries the next authentication type. When no more types are available to try,
67+
the SDK returns an error.
5568

5669
The following table details the environment variables that need to be set for each authentication type supported by environment-based authentication.
5770

@@ -68,14 +81,14 @@ The following table details the environment variables that need to be set for ea
6881
| | `AZURE_CLIENT_ID` | The application client ID. |
6982
| | `AZURE_USERNAME` | The username to sign in with. |
7083
| | `AZURE_PASSWORD` | The password to sign in with. |
71-
| __MSI__ | | MSI does not require any credentials to be set. The application must be running on an Azure resource configured to use MSI. For details, see [Managed Service Identity (MSI) for Azure resources]. |
84+
| __MSI__ | | No credentials are needed for MSI authentication. The application must be running on an Azure resource configured to use MSI. For details, see [Managed Service Identity (MSI) for Azure resources]. |
7285

73-
If you need to connect to a cloud or management endpoint other than the default Azure public cloud, you can also set the following environment variables. The most common reasons to set them are if you use Azure Stack, a cloud in a different geographic region, or the Azure Classic deployment model.
86+
To connect to a cloud or management endpoint other than the default Azure public cloud, set the following environment variables. The most common reasons are if you use Azure Stack, a cloud in a different geographic region, or the classic deployment model.
7487

7588
| Environment variable | Description |
7689
|----------------------|--------------|
7790
| `AZURE_ENVIRONMENT` | The name of the cloud environment to connect to. |
78-
| `AZURE_AD_RESOURCE` | The Active Directory resource ID to use when connecting. This should be a URI pointing to your management endpoint. |
91+
| `AZURE_AD_RESOURCE` | The Active Directory resource ID to use when connecting, as a URI to your management endpoint. |
7992

8093
When using environment-based authentication, call the [NewAuthorizerFromEnvironment](https://godoc.org/github.com/Azure/go-autorest/autorest/azure/auth#NewAuthorizerFromEnvironment) function to get your authorizer object. This object is then set
8194
on the `Authorizer` property of clients to allow them access to Azure.
@@ -96,18 +109,18 @@ To authenticate on Azure Stack, you need to set the following variables:
96109

97110
These variables can be retrieved from Azure Stack metadata information. To retrieve the metadata, open a web browser in your Azure Stack environment and use the url: `(ResourceManagerURL)/metadata/endpoints?api-version=1.0`
98111

99-
The `ResourceManagerURL` varies based on the region name, machine name and external fully qualified domain name (FQDN) of your Azure Stack deployment:
112+
The `ResourceManagerURL` varies based on the region name, machine name, and external fully qualified domain name (FQDN) of your Azure Stack deployment:
100113

101114
| Environment | ResourceManagerURL |
102115
|----------------------|--------------|
103116
| Development Kit | `https://management.local.azurestack.external/` |
104117
| Integrated Systems | `https://management.(region).ext-(machine-name).(FQDN)` |
105118

106-
For more details on how to use Azure SDK for Go on Azure Stack see [Use API version profiles with Go in Azure Stack](https://docs.microsoft.com/azure/azure-stack/user/azure-stack-version-profiles-go)
119+
For more information on how to use the Azure SDK for Go on Azure Stack, see [Use API version profiles with Go in Azure Stack](https://docs.microsoft.com/azure/azure-stack/user/azure-stack-version-profiles-go)
107120

108121
## Use file-based authentication
109122

110-
File-based authentication only works with client credentials when they are stored in a local file format generated by [the Azure CLI](/cli/azure). You can easily create this file when creating a new service principal with the `--sdk-auth` parameter. If you plan on using file-based authentication, make sure that this argument is provided when creating a service principal. Since the CLI prints output to `stdout`, redirect output to a file.
123+
File-based authentication uses a file format generated by [the Azure CLI](/cli/azure). You can easily create this file when creating a new service principal with the `--sdk-auth` parameter. If you plan on using file-based authentication, make sure that this argument is provided when creating a service principal. Since the CLI prints output to `stdout`, redirect output to a file.
111124

112125
```azurecli
113126
az ad sp create-for-rbac --sdk-auth > azure.auth
@@ -126,7 +139,7 @@ For more on using service principals and managing their access permissions, see
126139

127140
## Use device token authentication
128141

129-
If you want users to sign in interactively, the best way to offer that capability is through device token authentication. This authentication flow passes the user a token to paste into a Microsoft sign-in site, where they then authenticate with an Azure Active Directory (AAD) account. This authentication method supports accounts that have multi-factor authentication enabled, unlike standard username/password authentication.
142+
If you want users to sign in interactively, the best way is through device token authentication. This authentication flow passes the user a token to paste into a Microsoft sign-in site, where they then authenticate with an Azure Active Directory (AAD) account. This authentication method supports accounts that have multi-factor authentication enabled, unlike standard username/password authentication.
130143

131144
To use device token authentication, create a [DeviceFlowConfig](https://godoc.org/github.com/Azure/go-autorest/autorest/azure/auth#DeviceFlowConfig) authorizer with the [NewDeviceFlowConfig](https://godoc.org/github.com/Azure/go-autorest/autorest/azure/auth#NewDeviceFlowConfig) function. Call [Authorizer](https://godoc.org/github.com/Azure/go-autorest/autorest/azure/auth#DeviceFlowConfig.Authorizer) on the resulting object to start the authentication process. Device flow authentication blocks program execution until the whole authentication flow is complete.
132145

@@ -138,7 +151,11 @@ authorizer, err := deviceConfig.Authorizer()
138151

139152
## Use an authentication client
140153

141-
If you require a specific type of authentication and are willing to have your program do the work to load authentication information from the user, you can use any client that conforms to the [auth.AuthorizerConfig](https://godoc.org/github.com/Azure/go-autorest/autorest/azure/auth#AuthorizerConfig) interface. Use a type that implements this interface when you want an interactive program, use specialized configuration files, or have a requirement that prevents you from using another authentication method.
154+
If you require a specific type of authentication and are willing to have your program do the work to load authentication information from the user, you can use any client that conforms to the [auth.AuthorizerConfig](https://godoc.org/github.com/Azure/go-autorest/autorest/azure/auth#AuthorizerConfig) interface. Use a type that implements this interface when you:
155+
156+
* Write an interactive program
157+
* Use specialized configuration files
158+
* Have a requirement that prevents using a built-in authentication method
142159

143160
> [!WARNING]
144161
> Never hard-code Azure credentials into an application. Putting secrets into an application binary makes it easier for an attacker to
@@ -159,7 +176,7 @@ The following table lists the types in the SDK that conform to the `AuthorizerCo
159176
[DeviceFlowConfig]: https://godoc.org/github.com/Azure/go-autorest/autorest/azure/auth#DeviceFlowConfig
160177
[UsernamePasswordConfig]: https://godoc.org/github.com/Azure/go-autorest/autorest/azure/auth#UsernamePasswordConfig
161178

162-
Create an authenticator with its associated `New` function, and then call `Authorize` on the resulting object to perform authentication. For example, to use certificate-based authentication:
179+
Create an authenticator with its associated `New` function, and then call `Authorize` on the resulting object to authenticate. For example, to use certificate-based authentication:
163180

164181
```go
165182
import "github.com/Azure/go-autorest/autorest/azure/auth"

azure-go-sdk-conceptual/azure-sdk-go-compute-networking-samples.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Selected samples for working with compute resources like VMs and vi
44
author: sptramer
55
ms.author: sttramer
66
manager: carmonm
7-
ms.date: 03/21/2018
7+
ms.date: 09/05/2018
88
ms.topic: sample
99
ms.prod: azure
1010
ms.technology: azure-sdk-go
@@ -14,14 +14,14 @@ ms.devlang: go
1414

1515
# Azure SDK for Go samples for compute and networking
1616

17-
The following table links to selected samples of Go source code that you can use to manage VMs, virtual networks, and subnets in Azure.
17+
The following table links to selected samples that demonstrate the management of compute and virtual network resources in the Azure SDK for Go.
1818

1919
All samples for the Azure SDK for Go are available on [GitHub](https://github.com/Azure-Samples/azure-sdk-for-go-samples).
2020

2121
| Name | Description |
2222
|------|-------------|
2323
| [network/network](https://github.com/Azure-Samples/azure-sdk-for-go-samples/blob/master/network/network.go) | Create, update, delete, and query network resources including virtual networks, subnets, and network security groups. |
24-
| [compute/vm_disk](https://github.com/Azure-Samples/azure-sdk-for-go-samples/blob/master/compute/vm_disk.go) | Create, attach, detatch, update, and encrypt data disks for a VM. |
24+
| [compute/vm_disk](https://github.com/Azure-Samples/azure-sdk-for-go-samples/blob/master/compute/vm_disk.go) | Create, attach, detach, update, and encrypt data disks for a VM. |
2525
| [compute/vm](https://github.com/Azure-Samples/azure-sdk-for-go-samples/blob/master/compute/vm.go) | Create, update, deactivate, and manage VMs. |
2626
| [compute/vm_with_availabilityset](https://github.com/Azure-Samples/azure-sdk-for-go-samples/blob/master/compute/vm_with_availabilityset.go) | Create availability sets and load balancers for VMs. |
2727
| [compute/vm_with_identity](https://github.com/Azure-Samples/azure-sdk-for-go-samples/blob/master/compute/vm_with_identity.go) | Create and manage Managed Service Identities (MSIs) for VMs. |

azure-go-sdk-conceptual/azure-sdk-go-containers-samples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Selected samples for working with ACI and AKS from the Azure SDK fo
44
author: sptramer
55
ms.author: sttramer
66
manager: carmonm
7-
ms.date: 03/21/2018
7+
ms.date: 09/05/2018
88
ms.topic: sample
99
ms.prod: azure
1010
ms.technology: azure-sdk-go
@@ -14,7 +14,7 @@ ms.devlang: go
1414

1515
# Azure SDK for Go samples for containers
1616

17-
The following table links to selected samples of Go source code that you can use to work with containers on Azure via Azure Container Instances (ACI) or Azure Kubernetes Service (AKS).
17+
The following table links to selected samples that demonstrate the management of Azure Container Instances (ACI) and Azure Kubernetes Service (AKS) from the Azure SDK for Go.
1818

1919
All samples for the Azure SDK for Go are available on [GitHub](https://github.com/Azure-Samples/azure-sdk-for-go-samples).
2020

0 commit comments

Comments
 (0)