Skip to content

Commit 94b3c59

Browse files
committed
Updating article to include new v12 snippets
1 parent 48152f2 commit 94b3c59

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

articles/storage/blobs/storage-manage-access-to-resources.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author: tamram
77

88
ms.service: storage
99
ms.topic: how-to
10-
ms.date: 12/04/2019
10+
ms.date: 05/05/2020
1111
ms.author: tamram
1212
ms.reviewer: cbrooks
1313
---
@@ -47,6 +47,16 @@ The following screenshot shows how to change the public access level for the sel
4747
4848
### Set container public access level with .NET
4949

50+
# [\.NET v12 SDK](#tab/dotnet)
51+
52+
To set permissions for a container, call the [BlobContainerClient.SetAccessPolicy](https://docs.microsoft.com/dotnet/api/azure.storage.blobs.blobcontainerclient.setaccesspolicy?view=azure-dotnet) method.
53+
54+
The following example sets the container's permissions to full public read access. To set permissions to public read access for blobs only, pass the **PublicAccessType.Blob** field into the [BlobContainerClient.SetAccessPolicy](https://docs.microsoft.com/dotnet/api/azure.storage.blobs.blobcontainerclient.setaccesspolicy?view=azure-dotnet) method. To remove all permissions for anonymous users, use the **BlobContainerPublicAccessType.None** field.
55+
56+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/Security.cs" id="Snippet_SetPublicContainerPermissions":::
57+
58+
# [\.NET v11 SDK](#tab/dotnet11)
59+
5060
To set permissions for a container using the Azure Storage client library for .NET, first retrieve the container's existing permissions by calling one of the following methods:
5161

5262
- [GetPermissions](/dotnet/api/microsoft.azure.storage.blob.cloudblobcontainer.getpermissions)
@@ -72,6 +82,8 @@ private static async Task SetPublicContainerPermissions(CloudBlobContainer conta
7282
}
7383
```
7484

85+
---
86+
7587
## Access containers and blobs anonymously
7688

7789
A client that accesses containers and blobs anonymously can use constructors that do not require credentials. The following examples show a few different ways to reference containers and blobs anonymously.
@@ -80,6 +92,12 @@ A client that accesses containers and blobs anonymously can use constructors tha
8092

8193
You can create a new service client object for anonymous access by providing the Blob storage endpoint for the account. However, you must also know the name of a container in that account that's available for anonymous access.
8294

95+
# [\.NET v12 SDK](#tab/dotnet)
96+
97+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/Security.cs" id="Snippet_CreateAnonymousBlobClient":::
98+
99+
# [\.NET v11 SDK](#tab/dotnet11)
100+
83101
```csharp
84102
public static void CreateAnonymousBlobClient()
85103
{
@@ -96,12 +114,20 @@ public static void CreateAnonymousBlobClient()
96114
Console.WriteLine(container.Properties.LastModified);
97115
Console.WriteLine(container.Properties.ETag);
98116
}
99-
```
117+
```
118+
119+
---
100120

101121
### Reference a container anonymously
102122

103123
If you have the URL to a container that is anonymously available, you can use it to reference the container directly.
104124

125+
# [\.NET v12 SDK](#tab/dotnet)
126+
127+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/Security.cs" id="Snippet_ListBlobsAnonymously":::
128+
129+
# [\.NET v11 SDK](#tab/dotnet11)
130+
105131
```csharp
106132
public static void ListBlobsAnonymously()
107133
{
@@ -116,20 +142,30 @@ public static void ListBlobsAnonymously()
116142
Console.WriteLine(blobItem.Uri);
117143
}
118144
}
119-
```
145+
```
146+
147+
---
120148

121149
### Reference a blob anonymously
122150

123151
If you have the URL to a blob that is available for anonymous access, you can reference the blob directly using that URL:
124152

153+
# [\.NET v12 SDK](#tab/dotnet)
154+
155+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/dotnet-v12/Security.cs" id="Snippet_DownloadBlobAnonymously":::
156+
157+
# [\.NET v11 SDK](#tab/dotnet11)
158+
125159
```csharp
126160
public static void DownloadBlobAnonymously()
127161
{
128162
CloudBlockBlob blob = new CloudBlockBlob(
129163
new Uri(@"https://storagesamples.blob.core.windows.net/sample-container/logfile.txt"));
130164
blob.DownloadToFile(@"C:\Temp\logfile.txt", FileMode.Create);
131165
}
132-
```
166+
```
167+
168+
---
133169

134170
## Next steps
135171

0 commit comments

Comments
 (0)