Skip to content

Commit c03533c

Browse files
committed
Update Program.cs
1 parent 6068f3d commit c03533c

File tree

1 file changed

+2
-45
lines changed

1 file changed

+2
-45
lines changed

BlobStorage/Program.cs

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,11 @@ private static async Task BasicStorageBlockBlobOperationsAsync()
137137
Console.WriteLine("5. Create a read-only snapshot of the blob");
138138
CloudBlockBlob blockBlobSnapshot = await blockBlob.CreateSnapshotAsync(null, null, null, null);
139139

140-
// Create three new blocks and upload them to the existing blob
141-
Console.WriteLine("6. Create three new blocks and upload them to the existing blob");
142-
byte[] buffer = GetRandomBuffer(1024);
143-
List<string> blocks = GetBlockIdList(3);
144-
145-
foreach (string block in blocks)
146-
{
147-
using (MemoryStream memoryStream = new MemoryStream(buffer))
148-
{
149-
await blockBlob.PutBlockAsync(block, memoryStream, null);
150-
}
151-
}
152-
// Important: Please make sure that you call PutBlockList in order to commit the blocks to the blob
153-
await blockBlob.PutBlockListAsync(blocks, null, null, null);
154-
155140
// Clean up after the demo
156-
Console.WriteLine("7. Delete block Blob and all of its snapshots");
141+
Console.WriteLine("6. Delete block Blob and all of its snapshots");
157142
await blockBlob.DeleteIfExistsAsync(DeleteSnapshotsOption.IncludeSnapshots,null,null,null);
158143

159-
Console.WriteLine("8. Delete Container");
144+
Console.WriteLine("7. Delete Container");
160145
await container.DeleteIfExistsAsync();
161146
}
162147

@@ -249,33 +234,5 @@ private static CloudStorageAccount CreateStorageAccountFromConnectionString(stri
249234

250235
return storageAccount;
251236
}
252-
253-
/// <summary>
254-
/// Creates a new random byte array
255-
/// </summary>
256-
/// <param name="size">Size of the Byte Array</param>
257-
/// <returns>byte[] object</returns>
258-
public static byte[] GetRandomBuffer(int size)
259-
{
260-
byte[] buffer = new byte[size];
261-
Random random = new Random();
262-
random.NextBytes(buffer);
263-
return buffer;
264-
}
265-
266-
/// <summary>
267-
/// Returns the list of BlockIds
268-
/// </summary>
269-
/// <param name="count">Number of blocks</param>
270-
/// <returns>List(string) object</returns>
271-
public static List<string> GetBlockIdList(int count)
272-
{
273-
List<string> blocks = new List<string>();
274-
for (int i = 0; i < count; i++)
275-
{
276-
blocks.Add(Convert.ToBase64String(Guid.NewGuid().ToByteArray()));
277-
}
278-
return blocks;
279-
}
280237
}
281238
}

0 commit comments

Comments
 (0)