You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To learn more about creating a container, and to explore more code samples, see [Create a blob container with .NET](storage-blob-container-create.md).
177
+
176
178
### Upload a blob to a container
177
179
178
180
Add the following code to the end of the `Program.cs` class:
@@ -202,6 +204,8 @@ The code snippet completes the following steps:
202
204
1. Gets a reference to a [BlobClient](/dotnet/api/azure.storage.blobs.blobclient) object by calling the [GetBlobClient](/dotnet/api/azure.storage.blobs.blobcontainerclient.getblobclient) method on the container from the [Create a container](#create-a-container) section.
203
205
1. Uploads the local text file to the blob by calling the [UploadAsync](/dotnet/api/azure.storage.blobs.blobclient.uploadasync#Azure_Storage_Blobs_BlobClient_UploadAsync_System_String_System_Boolean_System_Threading_CancellationToken_) method. This method creates the blob if it doesn't already exist, and overwrites it if it does.
204
206
207
+
To learn more about uploading blobs, and to explore more code samples, see [Upload a blob with .NET](storage-blob-upload.md).
208
+
205
209
### List blobs in a container
206
210
207
211
List the blobs in the container by calling the [GetBlobsAsync](/dotnet/api/azure.storage.blobs.blobcontainerclient.getblobsasync) method. In this case, only one blob has been added to the container, so the listing operation returns just that one blob.
@@ -218,6 +222,8 @@ await foreach (BlobItem blobItem in containerClient.GetBlobsAsync())
218
222
}
219
223
```
220
224
225
+
To learn more about listing blobs, and to explore more code samples, see [List blobs with .NET](storage-blobs-list.md).
226
+
221
227
### Download a blob
222
228
223
229
Download the previously created blob by calling the [DownloadToAsync](/dotnet/api/azure.storage.blobs.specialized.blobbaseclient.downloadtoasync) method. The example code adds a suffix of "DOWNLOADED" to the file name so that you can see both files in local file system.
To learn more about downloading blobs, and to explore more code samples, see [Download a blob with .NET](storage-blob-download.md).
246
+
239
247
### Delete a container
240
248
241
249
The following code cleans up the resources the app created by deleting the entire container by using [DeleteAsync](/dotnet/api/azure.storage.blobs.blobcontainerclient.deleteasync). It also deletes the local files created by the app.
To learn more about deleting a container, and to explore more code samples, see [Delete and restore a blob container with .NET](storage-blob-container-delete.md).
271
+
262
272
## The completed code
263
273
264
274
After completing these steps the code in your `Program.cs` file should now resemble the following:
To learn more about creating a container, and to explore more code samples, see [Create a blob container with Java](storage-blob-container-create-java.md).
339
+
338
340
### Upload blobs to a container
339
341
340
342
Add this code to the end of the `Main` method:
@@ -347,6 +349,8 @@ The code snippet completes the following steps:
347
349
1. Gets a reference to a [BlobClient](/java/api/com.azure.storage.blob.blobclient) object by calling the [getBlobClient](/java/api/com.azure.storage.blob.blobcontainerclient.getblobclient) method on the container from the [Create a container](#create-a-container) section.
348
350
1. Uploads the local text file to the blob by calling the [uploadFromFile](/java/api/com.azure.storage.blob.blobclient.uploadfromfile) method. This method creates the blob if it doesn't already exist, but won't overwrite it if it does.
349
351
352
+
To learn more about uploading blobs, and to explore more code samples, see [Upload a blob with Java](storage-blob-upload-java.md).
353
+
350
354
### List the blobs in a container
351
355
352
356
List the blobs in the container by calling the [listBlobs](/java/api/com.azure.storage.blob.blobcontainerclient.listblobs) method. In this case, only one blob has been added to the container, so the listing operation returns just that one blob.
@@ -355,6 +359,8 @@ Add this code to the end of the `Main` method:
To learn more about listing blobs, and to explore more code samples, see [List blobs with Java](storage-blobs-list-java.md).
363
+
358
364
### Download blobs
359
365
360
366
Download the previously created blob by calling the [downloadToFile](/java/api/com.azure.storage.blob.specialized.blobclientbase.downloadtofile) method. The example code adds a suffix of "DOWNLOAD" to the file name so that you can see both files in local file system.
@@ -363,6 +369,8 @@ Add this code to the end of the `Main` method:
To learn more about downloading blobs, and to explore more code samples, see [Download a blob with Java](storage-blob-download-java.md).
373
+
366
374
### Delete a container
367
375
368
376
The following code cleans up the resources the app created by removing the entire container using the [delete](/java/api/com.azure.storage.blob.blobcontainerclient.delete) method. It also deletes the local files created by the app.
@@ -373,6 +381,8 @@ Add this code to the end of the `Main` method:
To learn more about deleting a container, and to explore more code samples, see [Delete and restore a blob container with Java](storage-blob-container-delete-java.md).
385
+
376
386
## Run the code
377
387
378
388
This app creates a test file in your local folder and uploads it to Blob storage. The example then lists the blobs in the container and downloads the file with a new name so that you can compare the old and new files.
The preceding code creates an instance of the [BlobServiceClient](/javascript/api/@azure/storage-blob/blobserviceclient) class by calling the [fromConnectionString](/javascript/api/@azure/storage-blob/blobserviceclient#fromconnectionstring-string--storagepipelineoptions-) method. Then, call the [getContainerClient](/javascript/api/@azure/storage-blob/blobserviceclient#getcontainerclient-string-) method to get a reference to a container. Finally, call [create](/javascript/api/@azure/storage-blob/containerclient#create-containercreateoptions-) to actually create the container in your storage account.
237
+
The preceding code takes a [BlobServiceClient](/javascript/api/@azure/storage-blob/blobserviceclient) object and calls the [getContainerClient](/javascript/api/@azure/storage-blob/blobserviceclient#getcontainerclient-string-) method to get a reference to a container. Finally, the code calls [create](/javascript/api/@azure/storage-blob/containerclient#create-containercreateoptions-) to actually create the container in your storage account.
238
+
239
+
To learn more about creating a container, and to explore more code samples, see [Create a blob container with JavaScript](storage-blob-container-create-javascript.md).
238
240
239
241
## Upload blobs to a container
240
242
@@ -245,6 +247,8 @@ Copy the following code to the end of the `main` function to upload a text strin
245
247
The preceding code gets a reference to a [BlockBlobClient](/javascript/api/@azure/storage-blob/blockblobclient) object by calling the [getBlockBlobClient](/javascript/api/@azure/storage-blob/containerclient#getblockblobclient-string-) method on the [ContainerClient](/javascript/api/@azure/storage-blob/containerclient) from the [Create a container](#create-a-container) section.
246
248
The code uploads the text string data to the blob by calling the [upload](/javascript/api/@azure/storage-blob/blockblobclient#upload-httprequestbody--number--blockblobuploadoptions-) method.
247
249
250
+
To learn more about uploading blobs, and to explore more code samples, see [Upload a blob with JavaScript](storage-blob-upload-javascript.md).
251
+
248
252
## List the blobs in a container
249
253
250
254
Add the following code to the end of the `main` function to list the blobs in the container.
@@ -253,6 +257,8 @@ Add the following code to the end of the `main` function to list the blobs in th
253
257
254
258
The preceding code calls the [listBlobsFlat](/javascript/api/@azure/storage-blob/containerclient#listblobsflat-containerlistblobsoptions-) method. In this case, only one blob has been added to the container, so the listing operation returns just that one blob.
255
259
260
+
To learn more about listing blobs, and to explore more code samples, see [List blobs with JavaScript](storage-blobs-list-javascript.md).
261
+
256
262
## Download blobs
257
263
258
264
1. Add the following code to the end of the `main` function to download the previously created blob into the app runtime.
@@ -265,6 +271,8 @@ The preceding code calls the [listBlobsFlat](/javascript/api/@azure/storage-blob
To learn more about downloading blobs, and to explore more code samples, see [Download a blob with JavaScript](storage-blob-download-javascript.md).
275
+
268
276
## Delete a container
269
277
270
278
Add this code to the end of the `main` function to delete the container and all its blobs:
@@ -273,6 +281,8 @@ Add this code to the end of the `main` function to delete the container and all
273
281
274
282
The preceding code cleans up the resources the app created by removing the entire container using the [delete](/javascript/api/@azure/storage-blob/containerclient#delete-containerdeletemethodoptions-) method. You can also delete the local files, if you like.
275
283
284
+
To learn more about deleting a container, and to explore more code samples, see [Delete and restore a blob container with JavaScript](storage-blob-container-delete-javascript.md).
285
+
276
286
## Run the code
277
287
278
288
1. From a Visual Studio Code terminal, run the app.
0 commit comments