Skip to content

Commit afe0914

Browse files
committed
Merge branch 'master' of https://github.com/MicrosoftDocs/azure-docs-pr into gen2DiskUpdate
2 parents 5be8891 + 5a738aa commit afe0914

File tree

3 files changed

+101
-37
lines changed

3 files changed

+101
-37
lines changed

articles/dev-spaces/how-to/manage-secrets.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "How to manage secrets when working with an Azure Dev Space"
33
services: azure-dev-spaces
4-
ms.date: "05/11/2018"
4+
ms.date: "12/03/2019"
55
ms.topic: "conceptual"
66
description: "Rapid Kubernetes development with containers and microservices on Azure"
77
keywords: "Docker, Kubernetes, Azure, AKS, Azure Container Service, containers"
@@ -10,7 +10,7 @@ keywords: "Docker, Kubernetes, Azure, AKS, Azure Container Service, containers"
1010

1111
Your services might require certain passwords, connection strings, and other secrets, such as for databases or other secure Azure services. By setting the values of these secrets in configuration files, you can make them available in your code as environment variables. These must be handled with care to avoid compromising the security of the secrets.
1212

13-
Azure Dev Spaces provides two recommended, streamlined options for storing secrets in Helm charts generated by the Azure Dev Spaces client tooling: in the values.dev.yaml file, and inline directly in azds.yaml. It's not recommended to store secrets in values.yaml. Outside of the two approaches for Helm charts generated by the client tooling defined in this article, if you create your own Helm chart, you can use the Helm chart directly to manage and store secrets.
13+
Azure Dev Spaces provides two recommended, streamlined options for storing secrets in Helm charts generated by the Azure Dev Spaces client tooling: in the `values.dev.yaml` file, and inline directly in `azds.yaml`. It's not recommended to store secrets in `values.yaml`. Outside of the two approaches for Helm charts generated by the client tooling defined in this article, if you create your own Helm chart, you can use the Helm chart directly to manage and store secrets.
1414

1515
## Method 1: values.dev.yaml
1616
1. Open VS Code with your project that is enabled for Azure Dev Spaces.
@@ -56,7 +56,7 @@ Azure Dev Spaces provides two recommended, streamlined options for storing secre
5656
7. Make sure that you add _values.dev.yaml_ to the _.gitignore_ file to avoid committing secrets in source control.
5757

5858

59-
## Method 2: Inline directly in azds.yaml
59+
## Method 2: azds.yaml
6060
1. In _azds.yaml_, set secrets under the yaml section configurations/develop/install. Although you can enter secret values directly there, it's not recommended because _azds.yaml_ is checked into source control. Instead, add placeholders using the "$PLACEHOLDER" syntax.
6161

6262
```yaml
@@ -99,6 +99,44 @@ Azure Dev Spaces provides two recommended, streamlined options for storing secre
9999
kubectl get secret --namespace default -o yaml
100100
```
101101

102+
## Passing secrets as build arguments
103+
104+
The previous sections showed how to pass secrets to use at container run time. You can also pass a secret at container build time, such as a password for a private NuGet, using `azds.yaml`.
105+
106+
In `azds.yaml`, set the build time secrets in *configurations.develop.build.args* using the `<variable name>: ${secret.<secret name>.<secret key>}` syntax. For example:
107+
108+
```yaml
109+
configurations:
110+
develop:
111+
build:
112+
dockerfile: Dockerfile.develop
113+
useGitIgnore: true
114+
args:
115+
BUILD_CONFIGURATION: ${BUILD_CONFIGURATION:-Debug}
116+
MYTOKEN: ${secret.mynugetsecret.pattoken}
117+
```
118+
119+
In the above example, *mynugetsecret* is an existing secret and *pattoken* is an existing key.
120+
121+
>[!NOTE]
122+
> Secret names and keys may contain the `.` character. Use `\` to escape `.` when passing secrets as build arguments. For example, to pass a secret named *foo.bar* with the key of *token*: `MYTOKEN: ${secret.foo\.bar.token}`. In addition, secrets can be evaluated with prefix and postfix text. For example, `MYURL: eus-${secret.foo\.bar.token}-version1`. Also, secrets available in parent and grandparent spaces can be passed as build arguments.
123+
124+
In your Dockerfile, use the *ARG* directive to consume the secret, then use that same variable later in the Dockerfile. For example:
125+
126+
```dockerfile
127+
...
128+
ARG MYTOKEN
129+
...
130+
ARG NUGET_EXTERNAL_FEED_ENDPOINTS="{'endpointCredentials': [{'endpoint':'PRIVATE_NUGET_ENDPOINT', 'password':'${MYTOKEN}'}]}"
131+
...
132+
```
133+
134+
Update the services running in your cluster with these changes. On the command line, run the command:
135+
136+
```
137+
azds up
138+
```
139+
102140
## Next steps
103141

104142
With these methods, you can now securely connect to a database, an Azure Cache for Redis, or access secure Azure services.

articles/storage/blobs/storage-blob-user-delegation-sas-create-dotnet.md

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: Create a user delegation SAS for a container or blob with .NET (preview) - Azure Storage
3-
description: Learn how to create a user delegation SAS using Azure Active Directory credentials in Azure Storage using the .NET client library.
3+
description: Learn how to create a user delegation SAS (preview) using Azure Active Directory credentials in Azure Storage using the .NET client library.
44
services: storage
55
author: tamram
66

77
ms.service: storage
88
ms.topic: conceptual
9-
ms.date: 10/17/2019
9+
ms.date: 12/03/2019
1010
ms.author: tamram
1111
ms.reviewer: cbrooks
1212
ms.subservice: blobs
@@ -16,13 +16,13 @@ ms.subservice: blobs
1616

1717
[!INCLUDE [storage-auth-sas-intro-include](../../../includes/storage-auth-sas-intro-include.md)]
1818

19-
This article shows how to use Azure Active Directory (Azure AD) credentials to create a user delegation SAS for a container or blob with the Azure Storage client library for .NET.
19+
This article shows how to use Azure Active Directory (Azure AD) credentials to create a user delegation SAS (preview) for a container or blob with the Azure Storage client library for .NET.
2020

2121
[!INCLUDE [storage-auth-user-delegation-include](../../../includes/storage-auth-user-delegation-include.md)]
2222

23-
## Authenticate with the Azure Identity library (preview)
23+
## Authenticate with the Azure Identity library
2424

25-
The Azure Identity client library for .NET (preview) authenticates a security principal. When your code is running in Azure, the security principal is a managed identity for Azure resources.
25+
The Azure Identity client library for .NET authenticates a security principal. When your code is running in Azure, the security principal is a managed identity for Azure resources.
2626

2727
When your code is running in the development environment, authentication may be handled automatically, or it may require a browser login, depending on which tools you're using. Microsoft Visual Studio supports single sign-on (SSO), so that the active Azure AD user account is automatically used for authentication. For more information about SSO, see [Single sign-on to applications](../../active-directory/manage-apps/what-is-single-sign-on.md).
2828

@@ -36,30 +36,30 @@ For more information about the Azure Identity client library, see [Azure Identit
3636

3737
When an Azure AD security principal attempts to access blob data, that security principal must have permissions to the resource. Whether the security principal is a managed identity in Azure or an Azure AD user account running code in the development environment, the security principal must be assigned an RBAC role that grants access to blob data in Azure Storage. For information about assigning permissions via RBAC, see the section titled **Assign RBAC roles for access rights** in [Authorize access to Azure blobs and queues using Azure Active Directory](../common/storage-auth-aad.md#assign-rbac-roles-for-access-rights).
3838

39-
## Install the preview packages
39+
## Install the packages
4040

41-
The examples in this article use the latest preview version of the [Azure Storage client library for Blob storage](https://www.nuget.org/packages/Azure.Storage.Blobs). To install the preview package, run the following command from the NuGet package manager console:
41+
The examples in this article use the latest version of the [Azure Storage client library for Blob storage](https://www.nuget.org/packages/Azure.Storage.Blobs). To install the package, run the following command from the NuGet package manager console:
4242

4343
```powershell
44-
Install-Package Azure.Storage.Blobs -IncludePrerelease
44+
Install-Package Azure.Storage.Blobs
4545
```
4646

47-
The examples in this article also use the latest preview version of the [Azure Identity client library for .NET](https://www.nuget.org/packages/Azure.Identity/) to authenticate with Azure AD credentials. To install the preview package, run the following command from the NuGet package manager console:
47+
The examples in this article also use the latest version of the [Azure Identity client library for .NET](https://www.nuget.org/packages/Azure.Identity/) to authenticate with Azure AD credentials. To install the package, run the following command from the NuGet package manager console:
4848

4949
```powershell
50-
Install-Package Azure.Identity -IncludePrerelease
50+
Install-Package Azure.Identity
5151
```
5252

5353
## Add using directives
5454

55-
Add the following `using` directives to your code to use the preview versions of the Azure Identity and Azure Storage client libraries.
55+
Add the following `using` directives to your code to use the Azure Identity and Azure Storage client libraries.
5656

5757
```csharp
5858
using System;
5959
using System.IO;
6060
using System.Threading.Tasks;
61+
using Azure;
6162
using Azure.Identity;
62-
using Azure.Storage;
6363
using Azure.Storage.Sas;
6464
using Azure.Storage.Blobs;
6565
using Azure.Storage.Blobs.Models;
@@ -72,8 +72,10 @@ To get a token credential that your code can use to authorize requests to Azure
7272
The following code snippet shows how to get the authenticated token credential and use it to create a service client for Blob storage:
7373

7474
```csharp
75+
// Construct the blob endpoint from the account name.
7576
string blobEndpoint = string.Format("https://{0}.blob.core.windows.net", accountName);
7677

78+
// Create a new Blob service client with Azure AD credentials.
7779
BlobServiceClient blobClient = new BlobServiceClient(new Uri(blobEndpoint),
7880
new DefaultAzureCredential());
7981
```
@@ -92,14 +94,17 @@ Use one of the following methods to request the user delegation key:
9294
The following code snippet gets the user delegation key and writes out its properties:
9395

9496
```csharp
97+
// Get a user delegation key for the Blob service that's valid for seven days.
98+
// You can use the key to generate any number of shared access signatures over the lifetime of the key.
9599
UserDelegationKey key = await blobClient.GetUserDelegationKeyAsync(DateTimeOffset.UtcNow,
96100
DateTimeOffset.UtcNow.AddDays(7));
97101

102+
// Read the key's properties.
98103
Console.WriteLine("User delegation key properties:");
99-
Console.WriteLine("Key signed start: {0}", key.SignedStart);
100-
Console.WriteLine("Key signed expiry: {0}", key.SignedExpiry);
101-
Console.WriteLine("Key signed object ID: {0}", key.SignedOid);
102-
Console.WriteLine("Key signed tenant ID: {0}", key.SignedTid);
104+
Console.WriteLine("Key signed start: {0}", key.SignedStartsOn);
105+
Console.WriteLine("Key signed expiry: {0}", key.SignedExpiresOn);
106+
Console.WriteLine("Key signed object ID: {0}", key.SignedObjectId);
107+
Console.WriteLine("Key signed tenant ID: {0}", key.SignedTenantId);
103108
Console.WriteLine("Key signed service: {0}", key.SignedService);
104109
Console.WriteLine("Key signed version: {0}", key.SignedVersion);
105110
```
@@ -109,18 +114,23 @@ Console.WriteLine("Key signed version: {0}", key.SignedVersion);
109114
The following code snippet shows create a new [BlobSasBuilder](/dotnet/api/azure.storage.sas.blobsasbuilder) and provide the parameters for the user delegation SAS. The snippet then calls the [ToSasQueryParameters](/dotnet/api/azure.storage.sas.blobsasbuilder.tosasqueryparameters) to get the SAS token string. Finally, the code builds the complete URI, including the resource address and SAS token.
110115

111116
```csharp
112-
BlobSasBuilder builder = new BlobSasBuilder()
117+
// Create a SAS token that's valid for one hour.
118+
BlobSasBuilder sasBuilder = new BlobSasBuilder()
113119
{
114-
ContainerName = containerName,
120+
BlobContainerName = containerName,
115121
BlobName = blobName,
116-
Permissions = "r",
117122
Resource = "b",
118-
StartTime = DateTimeOffset.UtcNow,
119-
ExpiryTime = DateTimeOffset.UtcNow.AddMinutes(5)
123+
StartsOn = DateTimeOffset.UtcNow,
124+
ExpiresOn = DateTimeOffset.UtcNow.AddHours(1)
120125
};
121126

127+
// Specify read permissions for the SAS.
128+
sasBuilder.SetPermissions(BlobSasPermissions.Read);
129+
130+
// Use the key to get the SAS token.
122131
string sasToken = sasBuilder.ToSasQueryParameters(key, accountName).ToString();
123132

133+
// Construct the full URI, including the SAS token.
124134
UriBuilder fullUri = new UriBuilder()
125135
{
126136
Scheme = "https",
@@ -145,30 +155,33 @@ async static Task<Uri> GetUserDelegationSasBlob(string accountName, string conta
145155
new DefaultAzureCredential());
146156

147157
// Get a user delegation key for the Blob service that's valid for seven days.
148-
// Use the key to generate any number of shared access signatures over the lifetime of the key.
149-
UserDelegationKey key = await blobClient.GetUserDelegationKeyAsync(DateTimeOffset.UtcNow,
150-
DateTimeOffset.UtcNow.AddDays(7));
158+
// You can use the key to generate any number of shared access signatures over the lifetime of the key.
159+
UserDelegationKey key = await blobClient.GetUserDelegationKeyAsync(DateTimeOffset.UtcNow,
160+
DateTimeOffset.UtcNow.AddDays(7));
151161

152162
// Read the key's properties.
153163
Console.WriteLine("User delegation key properties:");
154-
Console.WriteLine("Key signed start: {0}", key.SignedStart);
155-
Console.WriteLine("Key signed expiry: {0}", key.SignedExpiry);
156-
Console.WriteLine("Key signed object ID: {0}", key.SignedOid);
157-
Console.WriteLine("Key signed tenant ID: {0}", key.SignedTid);
164+
Console.WriteLine("Key signed start: {0}", key.SignedStartsOn);
165+
Console.WriteLine("Key signed expiry: {0}", key.SignedExpiresOn);
166+
Console.WriteLine("Key signed object ID: {0}", key.SignedObjectId);
167+
Console.WriteLine("Key signed tenant ID: {0}", key.SignedTenantId);
158168
Console.WriteLine("Key signed service: {0}", key.SignedService);
159169
Console.WriteLine("Key signed version: {0}", key.SignedVersion);
170+
Console.WriteLine();
160171

161-
// Create a SAS token that's valid a short interval.
172+
// Create a SAS token that's valid for one hour.
162173
BlobSasBuilder sasBuilder = new BlobSasBuilder()
163174
{
164-
ContainerName = containerName,
175+
BlobContainerName = containerName,
165176
BlobName = blobName,
166-
Permissions = "r",
167177
Resource = "b",
168-
StartTime = DateTimeOffset.UtcNow,
169-
ExpiryTime = DateTimeOffset.UtcNow.AddMinutes(5)
178+
StartsOn = DateTimeOffset.UtcNow,
179+
ExpiresOn = DateTimeOffset.UtcNow.AddHours(1)
170180
};
171181

182+
// Specify read permissions for the SAS.
183+
sasBuilder.SetPermissions(BlobSasPermissions.Read);
184+
172185
// Use the key to get the SAS token.
173186
string sasToken = sasBuilder.ToSasQueryParameters(key, accountName).ToString();
174187

@@ -182,6 +195,7 @@ async static Task<Uri> GetUserDelegationSasBlob(string accountName, string conta
182195
};
183196

184197
Console.WriteLine("User delegation SAS URI: {0}", fullUri);
198+
Console.WriteLine();
185199
return fullUri.Uri;
186200
}
187201
```
@@ -216,7 +230,7 @@ private static async Task ReadBlobWithSasAsync(Uri sasUri)
216230
Console.WriteLine("Read operation succeeded for SAS {0}", sasUri);
217231
Console.WriteLine();
218232
}
219-
catch (StorageRequestFailedException e)
233+
catch (RequestFailedException e)
220234
{
221235
// Check for a 403 (Forbidden) error. If the SAS is invalid,
222236
// Azure Storage returns this error.

docfx.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@
408408
"articles/backup/**/*.md": "carmonm",
409409
"articles/site-recovery/**/*.md": "carmonm",
410410
"articles/migrate/**/*.md": "carmonm",
411+
"articles/virtual-machines/**/*.md": "gwallace",
412+
"articles/virtual-machine-scale-sets/**/*.md": "gwallace",
411413
"articles/notebooks/*.md": "barbkess"
412414
},
413415
"ms.author": {
@@ -437,6 +439,10 @@
437439
"articles/dev-spaces/**/*.md": "zarhoads",
438440
"articles/site-recovery/*.md": "raynew",
439441
"articles/migrate/*.md": "raynew",
442+
"articles/virtual-machines/linux/*.md": "cynthn",
443+
"articles/virtual-machines/windows/*.md": "cynthn",
444+
"articles/virtual-machines/*.md": "cynthn",
445+
"articles/virtual-machines-scale-sets/*.md": "jushiman",
440446
"articles/notebooks/*.md": "kraigb"
441447
},
442448
"ms.service": {
@@ -460,6 +466,8 @@
460466
"articles/jenkins/**/*.md": "jenkins",
461467
"articles/terraform/**/*.md": "terraform",
462468
"articles/lighthouse/**/*.md": "lighthouse",
469+
"articles/virtual-machines/*.md": "virtual-machines",
470+
"articles/virtual-machine-scale-sets/*.md": "virtual-machine-scale-sets",
463471
"articles/azure-resource-manager/**/*.md": "azure-resource-manager",
464472
"articles/dev-spaces/**/*.md": "azure-dev-spaces",
465473
"articles/site-recovery/*.md": "site-recovery",
@@ -535,6 +543,10 @@
535543
"articles/app-service/scripts/*.yml": "Azure App Service",
536544
"articles/app-service/environment/*.md": "Azure App Service Environment",
537545
"articles/app-service/environment/*.yml": "Azure App Service Environment",
546+
"articles/virtual-machines/*.md": "Azure Virtual Machines",
547+
"articles/virtual-machines/*.yml": "Azure Virtual Machines",
548+
"articles/virtual-machine-scale-sets/*.md": "Azure Virtual Machine Scale Sets",
549+
"articles/virtual-machine-scale-sets/*.yml": "Azure Virtual Machine Scale Sets",
538550
"articles/app-service-mobile/**/*.md": "Azure Mobile Apps",
539551
"articles/app-service-mobile/**/*.yml": "Azure Mobile Apps"
540552
},

0 commit comments

Comments
 (0)