Skip to content

Commit 5c1d660

Browse files
authored
Merge pull request #190484 from itechedit/quick-create-go
edit pass: quick-create-go.md
2 parents 4057425 + 1484882 commit 5c1d660

File tree

1 file changed

+47
-48
lines changed

1 file changed

+47
-48
lines changed

articles/key-vault/secrets/quick-create-go.md

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: QuickstartAzure Key Vault Go client library – manage secrets
3-
description: Learn how to create, retrieve, and delete secrets from an Azure key vault using the Go client library
2+
title: 'Quickstart: Manage secrets by using the Azure Key Vault Go client library'
3+
description: Learn how to create, retrieve, and delete secrets from an Azure key vault by using the Go client library.
44
author: Duffney
55
ms.author: jduffney
66
ms.date: 12/29/2021
@@ -10,61 +10,60 @@ ms.topic: quickstart
1010
ms.devlang: golang
1111
---
1212

13-
# Quickstart: Azure Key Vault secret client library for Go
13+
# Quickstart: Manage secrets by using the Azure Key Vault Go client library
1414

15-
In this quickstart, you'll learn to use the Azure SDK for Go to create, retrieve, list, and delete secrets from Azure Key Vault.
15+
In this quickstart, you'll learn how to use the Azure SDK for Go to create, retrieve, list, and delete secrets from an Azure key vault.
1616

17-
Azure Key Vault can store [several objects types](../general/about-keys-secrets-certificates.md#object-types). But, this quickstart focuses on secrets. By using Azure Key Vault to store secrets, you avoid storing secrets in your code, which increases the security of your applications.
17+
You can store a variety of [object types](../general/about-keys-secrets-certificates.md#object-types) in an Azure key vault. When you store secrets in a key vault, you avoid having to store them in your code, which helps improve the security of your applications.
1818

19-
Get started with the [azsecrets](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets) package and learn how to manage Azure Key Vault secrets using Go.
19+
Get started with the [azsecrets](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets) package and learn how to manage your secrets in an Azure key vault by using Go.
2020

2121
## Prerequisites
2222

23-
- An Azure subscription - [create one for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
24-
- **Go installed**: Version 1.16 or [above](https://golang.org/dl/)
25-
- [Azure CLI](/cli/azure/install-azure-cli)
23+
- An Azure subscription. If you don't already have a subscription, you can [create one for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
24+
- [Go version 1.16 or later](https://golang.org/dl/), installed.
25+
- [The Azure CLI](/cli/azure/install-azure-cli), installed.
2626

2727
## Setup
2828

29-
This quickstart uses the [azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity) package to authenticate to Azure using Azure CLI. To learn more about different methods of authentication, see [Azure authentication with the Azure SDK for Go](/azure/developer/go/azure-sdk-authentication).
29+
For purposes of this quickstart, you use the [azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity) package to authenticate to Azure by using the Azure CLI. To learn about the various authentication methods, see [Azure authentication with the Azure SDK for Go](/azure/developer/go/azure-sdk-authentication).
3030

31-
### Sign into Azure
31+
### Sign in to the Azure portal
3232

33-
1. Run the `az login` command:
33+
1. In the Azure CLI, run the following command:
3434

3535
```azurecli-interactive
3636
az login
3737
```
3838
39-
If the CLI can open your default browser, it will do so and load an Azure sign-in page.
39+
If the Azure CLI can open your default browser, it will do so on the Azure portal sign-in page.
4040
41-
Otherwise, open a browser page at [https://aka.ms/devicelogin](https://aka.ms/devicelogin) and enter the
42-
authorization code displayed in your terminal.
41+
If the page doesn't open automatically, go to [https://aka.ms/devicelogin](https://aka.ms/devicelogin), and then enter the authorization code that's displayed in your terminal.
4342
44-
1. Sign in with your account credentials in the browser.
43+
1. Sign in to the Azure portal with your account credentials.
4544
4645
### Create a resource group and key vault instance
4746
48-
1. Run the following Azure CLI commands:
47+
Run the following Azure CLI commands:
4948
50-
```azurecli
51-
az group create --name quickstart-rg --location eastus
52-
az keyvault create --name quickstart-kv --resource-group quickstart-rg
53-
```
49+
```azurecli
50+
az group create --name quickstart-rg --location eastus
51+
az keyvault create --name quickstart-kv --resource-group quickstart-rg
52+
```
5453

5554
### Create a new Go module and install packages
5655

57-
1. Run the following Go commands:
56+
Run the following Go commands:
5857

59-
```azurecli
60-
go mod init kvSecrets
61-
go get -u github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets
62-
go get -u github.com/Azure/azure-sdk-for-go/sdk/azidentity
63-
```
58+
```azurecli
59+
go mod init kvSecrets
60+
go get -u github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets
61+
go get -u github.com/Azure/azure-sdk-for-go/sdk/azidentity
62+
```
6463

6564
## Code examples
6665

67-
This Code examples section shows how to create a client, set a secret, retrieve a secret, and delete a secret.
66+
In the following sections, you create a client, set a secret, retrieve a secret, and delete a secret.
6867

6968
### Authenticate and create a client
7069

@@ -80,7 +79,7 @@ if err != nil {
8079
}
8180
```
8281

83-
If you used a different Key Vault name, replace `quickstart-kv` with your vault's name.
82+
If you used a different key vault name, replace `quickstart-kv` with that name.
8483

8584
### Create a secret
8685

@@ -104,7 +103,7 @@ if err != nil {
104103
fmt.Printf("secretValue: %s\n", *getResp.Value)
105104
```
106105

107-
### Lists secrets
106+
### List secrets
108107

109108
```go
110109
pager := client.ListSecrets(nil)
@@ -130,9 +129,9 @@ if err != nil {
130129
}
131130
```
132131

133-
## Sample Code
132+
## Sample code
134133

135-
Create a file named `main.go` and copy the following code into the file:
134+
Create a file named *main.go*, and then paste the following code into it:
136135

137136
```go
138137
package main
@@ -205,28 +204,28 @@ func main() {
205204

206205
## Run the code
207206

208-
Before you run the code, create an environment variable named `KEY_VAULT_NAME`. Set the environment variable's value to the name of the Azure Key Vault created previously.
207+
1. Before you run the code, create an environment variable named `KEY_VAULT_NAME`. Set the environment variable value to the name of the key vault that you created previously.
209208

210-
```azurecli
211-
export KEY_VAULT_NAME=quickstart-kv
212-
```
209+
```azurecli
210+
export KEY_VAULT_NAME=quickstart-kv
211+
```
213212

214-
Run the following `go run` command to run the Go app:
213+
1. To start the Go app, run the following command:
215214

216-
```azurecli
217-
go run main.go
218-
```
215+
```azurecli
216+
go run main.go
217+
```
219218

220-
```output
221-
secretValue: createdWithGO
222-
Secret ID: https://quickstart-kv.vault.azure.net/secrets/quickstart-secret
223-
Secret ID: https://quickstart-kv.vault.azure.net/secrets/secretName
224-
quickstart-secret has been deleted
225-
```
219+
```output
220+
secretValue: createdWithGO
221+
Secret ID: https://quickstart-kv.vault.azure.net/secrets/quickstart-secret
222+
Secret ID: https://quickstart-kv.vault.azure.net/secrets/secretName
223+
quickstart-secret has been deleted
224+
```
226225

227226
## Clean up resources
228227

229-
Run the following command to delete the resource group and all its remaining resources:
228+
Delete the resource group and all its remaining resources by running the following command:
230229

231230
```azurecli
232231
az group delete --resource-group quickstart-rg
@@ -235,6 +234,6 @@ az group delete --resource-group quickstart-rg
235234
## Next steps
236235

237236
- [Overview of Azure Key Vault](../general/overview.md)
238-
- [Azure Key Vault developer's guide](../general/developers-guide.md)
237+
- [Azure Key Vault developers guide](../general/developers-guide.md)
239238
- [Key Vault security overview](../general/security-features.md)
240239
- [Authenticate with Key Vault](../general/authentication.md)

0 commit comments

Comments
 (0)