diff --git a/AMSV3Tutorials/AnalyzeVideos/AnalyzeVideos.csproj b/AMSV3Tutorials/AnalyzeVideos/AnalyzeVideos.csproj index 5a41649..5f55002 100644 --- a/AMSV3Tutorials/AnalyzeVideos/AnalyzeVideos.csproj +++ b/AMSV3Tutorials/AnalyzeVideos/AnalyzeVideos.csproj @@ -12,11 +12,11 @@ - - - - - + + + + + diff --git a/AMSV3Tutorials/AnalyzeVideos/Program.cs b/AMSV3Tutorials/AnalyzeVideos/Program.cs index acaa58f..f4b4f44 100644 --- a/AMSV3Tutorials/AnalyzeVideos/Program.cs +++ b/AMSV3Tutorials/AnalyzeVideos/Program.cs @@ -3,10 +3,10 @@ using System.IO; using System.Linq; using System.Threading.Tasks; - +using Azure.Storage.Blobs; +using Azure.Storage.Blobs.Models; using Microsoft.Azure.Management.Media; using Microsoft.Azure.Management.Media.Models; -using Microsoft.Azure.Storage.Blob; using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.Rest; @@ -233,11 +233,11 @@ private static async Task CreateInputAssetAsync( // Use Storage API to get a reference to the Asset container // that was created by calling Asset's CreateOrUpdate method. - CloudBlobContainer container = new CloudBlobContainer(sasUri); - var blob = container.GetBlockBlobReference(Path.GetFileName(fileToUpload)); + BlobContainerClient container = new BlobContainerClient(sasUri); + BlobClient blob = container.GetBlobClient(Path.GetFileName(fileToUpload)); - // Use Strorage API to upload the file into the container in storage. - await blob.UploadFromFileAsync(fileToUpload); + // Use Storage API to upload the file into the container in storage. + await blob.UploadAsync(fileToUpload); return asset; } @@ -395,38 +395,35 @@ private static async Task DownloadOutputAssetAsync( expiryTime: DateTime.UtcNow.AddHours(1).ToUniversalTime()); Uri containerSasUrl = new Uri(assetContainerSas.AssetContainerSasUrls.FirstOrDefault()); - CloudBlobContainer container = new CloudBlobContainer(containerSasUrl); + BlobContainerClient container = new BlobContainerClient(containerSasUrl); string directory = Path.Combine(outputFolderName, assetName); Directory.CreateDirectory(directory); Console.WriteLine($"Downloading output results to '{directory}'..."); - BlobContinuationToken continuationToken = null; + string continuationToken = null; IList downloadTasks = new List(); do { - // A non-negative integer value that indicates the maximum number of results to be returned at a time, - // up to the per-operation limit of 5000. If this value is null, the maximum possible number of results - // will be returned, up to 5000. - int? ListBlobsSegmentMaxResult = null; - - BlobResultSegment segment = await container.ListBlobsSegmentedAsync(null, true, BlobListingDetails.None, ListBlobsSegmentMaxResult, continuationToken, null, null); + var resultSegment = container.GetBlobs().AsPages(continuationToken); - foreach (IListBlobItem blobItem in segment.Results) + foreach (Azure.Page blobPage in resultSegment) { - if (blobItem is CloudBlockBlob blob) + foreach (BlobItem blobItem in blobPage.Values) { - string path = Path.Combine(directory, blob.Name); + var blobClient = container.GetBlobClient(blobItem.Name); + string filename = Path.Combine(directory, blobItem.Name); - downloadTasks.Add(blob.DownloadToFileAsync(path, FileMode.Create)); + downloadTasks.Add(blobClient.DownloadToAsync(filename)); } + // Get the continuation token and loop until it is empty. + continuationToken = blobPage.ContinuationToken; } - continuationToken = segment.ContinuationToken; - } - while (continuationToken != null); + + } while (continuationToken != ""); await Task.WhenAll(downloadTasks); diff --git a/AMSV3Tutorials/EncryptWithAES/EncryptWithAES.csproj b/AMSV3Tutorials/EncryptWithAES/EncryptWithAES.csproj index 9fd7808..2539ad1 100644 --- a/AMSV3Tutorials/EncryptWithAES/EncryptWithAES.csproj +++ b/AMSV3Tutorials/EncryptWithAES/EncryptWithAES.csproj @@ -11,13 +11,13 @@ - + - - - - - + + + + + @@ -31,7 +31,7 @@ - + diff --git a/AMSV3Tutorials/EncryptWithAES/Program.cs b/AMSV3Tutorials/EncryptWithAES/Program.cs index 4310a37..c4cc213 100644 --- a/AMSV3Tutorials/EncryptWithAES/Program.cs +++ b/AMSV3Tutorials/EncryptWithAES/Program.cs @@ -4,12 +4,11 @@ using System.IO; using System.Linq; using System.Security.Claims; -using System.Security.Cryptography; using System.Threading.Tasks; - +using Azure.Storage.Blobs; +using Azure.Storage.Blobs.Models; using Microsoft.Azure.Management.Media; using Microsoft.Azure.Management.Media.Models; -using Microsoft.Azure.Storage.Blob; using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.IdentityModel.Tokens; @@ -549,38 +548,34 @@ private static async Task DownloadOutputAssetAsync( expiryTime: DateTime.UtcNow.AddHours(1).ToUniversalTime()); Uri containerSasUrl = new Uri(assetContainerSas.AssetContainerSasUrls.FirstOrDefault()); - CloudBlobContainer container = new CloudBlobContainer(containerSasUrl); + BlobContainerClient container = new BlobContainerClient(containerSasUrl); string directory = Path.Combine(outputFolderName, assetName); Directory.CreateDirectory(directory); Console.WriteLine($"Downloading output results to '{directory}'..."); - BlobContinuationToken continuationToken = null; + string continuationToken = null; IList downloadTasks = new List(); do { - // A non-negative integer value that indicates the maximum number of results to be returned at a time, - // up to the per-operation limit of 5000. If this value is null, the maximum possible number of results - // will be returned, up to 5000. - int? ListBlobsSegmentMaxResult = null; - - BlobResultSegment segment = await container.ListBlobsSegmentedAsync(null, true, BlobListingDetails.None, ListBlobsSegmentMaxResult, continuationToken, null, null); + var resultSegment = container.GetBlobs().AsPages(continuationToken); - foreach (IListBlobItem blobItem in segment.Results) + foreach (Azure.Page blobPage in resultSegment) { - if (blobItem is CloudBlockBlob blob) + foreach (BlobItem blobItem in blobPage.Values) { - string path = Path.Combine(directory, blob.Name); + var blobClient = container.GetBlobClient(blobItem.Name); + string filename = Path.Combine(directory, blobItem.Name); - downloadTasks.Add(blob.DownloadToFileAsync(path, FileMode.Create)); + downloadTasks.Add(blobClient.DownloadToAsync(filename)); } + // Get the continuation token and loop until it is empty. + continuationToken = blobPage.ContinuationToken; } - continuationToken = segment.ContinuationToken; - } - while (continuationToken != null); + } while (continuationToken != ""); await Task.WhenAll(downloadTasks); diff --git a/AMSV3Tutorials/EncryptWithDRM/EncryptWithDRM.csproj b/AMSV3Tutorials/EncryptWithDRM/EncryptWithDRM.csproj index 20a5956..1f4426d 100644 --- a/AMSV3Tutorials/EncryptWithDRM/EncryptWithDRM.csproj +++ b/AMSV3Tutorials/EncryptWithDRM/EncryptWithDRM.csproj @@ -11,13 +11,13 @@ - + - - - - - + + + + + @@ -29,7 +29,7 @@ - + diff --git a/AMSV3Tutorials/EncryptWithDRM/Program.cs b/AMSV3Tutorials/EncryptWithDRM/Program.cs index 64e592a..14073fd 100644 --- a/AMSV3Tutorials/EncryptWithDRM/Program.cs +++ b/AMSV3Tutorials/EncryptWithDRM/Program.cs @@ -6,10 +6,10 @@ using System.Security.Claims; using System.Security.Cryptography.X509Certificates; using System.Threading.Tasks; - +using Azure.Storage.Blobs; +using Azure.Storage.Blobs.Models; using Microsoft.Azure.Management.Media; using Microsoft.Azure.Management.Media.Models; -using Microsoft.Azure.Storage.Blob; using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.IdentityModel.Tokens; @@ -701,38 +701,34 @@ private static async Task DownloadOutputAssetAsync( expiryTime: DateTime.UtcNow.AddHours(1).ToUniversalTime()); Uri containerSasUrl = new Uri(assetContainerSas.AssetContainerSasUrls.FirstOrDefault()); - CloudBlobContainer container = new CloudBlobContainer(containerSasUrl); + BlobContainerClient container = new BlobContainerClient(containerSasUrl); string directory = Path.Combine(outputFolderName, assetName); Directory.CreateDirectory(directory); Console.WriteLine($"Downloading output results to '{directory}'..."); - BlobContinuationToken continuationToken = null; + string continuationToken = null; IList downloadTasks = new List(); do { - // A non-negative integer value that indicates the maximum number of results to be returned at a time, - // up to the per-operation limit of 5000. If this value is null, the maximum possible number of results - // will be returned, up to 5000. - int? ListBlobsSegmentMaxResult = null; - - BlobResultSegment segment = await container.ListBlobsSegmentedAsync(null, true, BlobListingDetails.None, ListBlobsSegmentMaxResult, continuationToken, null, null); + var resultSegment = container.GetBlobs().AsPages(continuationToken); - foreach (IListBlobItem blobItem in segment.Results) + foreach (Azure.Page blobPage in resultSegment) { - if (blobItem is CloudBlockBlob blob) + foreach (BlobItem blobItem in blobPage.Values) { - string path = Path.Combine(directory, blob.Name); + var blobClient = container.GetBlobClient(blobItem.Name); + string filename = Path.Combine(directory, blobItem.Name); - downloadTasks.Add(blob.DownloadToFileAsync(path, FileMode.Create)); + downloadTasks.Add(blobClient.DownloadToAsync(filename)); } + // Get the continuation token and loop until it is empty. + continuationToken = blobPage.ContinuationToken; } - continuationToken = segment.ContinuationToken; - } - while (continuationToken != null); + } while (continuationToken != ""); await Task.WhenAll(downloadTasks); diff --git a/AMSV3Tutorials/UploadEncodeAndStreamFiles/Program.cs b/AMSV3Tutorials/UploadEncodeAndStreamFiles/Program.cs index 0f12b35..6bcb886 100644 --- a/AMSV3Tutorials/UploadEncodeAndStreamFiles/Program.cs +++ b/AMSV3Tutorials/UploadEncodeAndStreamFiles/Program.cs @@ -3,10 +3,10 @@ using System.IO; using System.Linq; using System.Threading.Tasks; - +using Azure.Storage.Blobs; +using Azure.Storage.Blobs.Models; using Microsoft.Azure.Management.Media; using Microsoft.Azure.Management.Media.Models; -using Microsoft.Azure.Storage.Blob; using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.Rest; @@ -36,7 +36,7 @@ public static async Task Main(string[] args) { if (exception.Source.Contains("ActiveDirectory")) { - Console.Error.WriteLine("TIP: Make sure that you have filled out the appsettings.json file before running this sample."); + Console.Error.WriteLine("TIP: Make sure that you have filled out the appsettings.json file before running this sample."); } Console.Error.WriteLine($"{exception.Message}"); @@ -193,11 +193,11 @@ private static async Task CreateInputAssetAsync( // Use Storage API to get a reference to the Asset container // that was created by calling Asset's CreateOrUpdate method. - CloudBlobContainer container = new CloudBlobContainer(sasUri); - var blob = container.GetBlockBlobReference(Path.GetFileName(fileToUpload)); + BlobContainerClient container = new BlobContainerClient(sasUri); + BlobClient blob = container.GetBlobClient(Path.GetFileName(fileToUpload)); // Use Strorage API to upload the file into the container in storage. - await blob.UploadFromFileAsync(fileToUpload); + await blob.UploadAsync(fileToUpload); return asset; } @@ -226,9 +226,9 @@ private static async Task CreateOutputAssetAsync(IAzureMediaServicesClien // You may want to update this part to throw an Exception instead, and handle name collisions differently. string uniqueness = $"-{Guid.NewGuid():N}"; outputAssetName += uniqueness; - + Console.WriteLine("Warning – found an existing Asset with name = " + assetName); - Console.WriteLine("Creating an Asset with this name instead: " + outputAssetName); + Console.WriteLine("Creating an Asset with this name instead: " + outputAssetName); } return await client.Assets.CreateOrUpdateAsync(resourceGroupName, accountName, outputAssetName, asset); @@ -485,38 +485,34 @@ private static async Task DownloadOutputAssetAsync( expiryTime: DateTime.UtcNow.AddHours(1).ToUniversalTime()); Uri containerSasUrl = new Uri(assetContainerSas.AssetContainerSasUrls.FirstOrDefault()); - CloudBlobContainer container = new CloudBlobContainer(containerSasUrl); + BlobContainerClient container = new BlobContainerClient(containerSasUrl); string directory = Path.Combine(outputFolderName, assetName); Directory.CreateDirectory(directory); Console.WriteLine($"Downloading output results to '{directory}'..."); - BlobContinuationToken continuationToken = null; + string continuationToken = null; IList downloadTasks = new List(); do { - // A non-negative integer value that indicates the maximum number of results to be returned at a time, - // up to the per-operation limit of 5000. If this value is null, the maximum possible number of results - // will be returned, up to 5000. - int? ListBlobsSegmentMaxResult = null; - - BlobResultSegment segment = await container.ListBlobsSegmentedAsync(null, true, BlobListingDetails.None, ListBlobsSegmentMaxResult, continuationToken, null, null); - - foreach (IListBlobItem blobItem in segment.Results) + var resultSegment = container.GetBlobs().AsPages(continuationToken); + + foreach (Azure.Page blobPage in resultSegment) { - if (blobItem is CloudBlockBlob blob) + foreach (BlobItem blobItem in blobPage.Values) { - string path = Path.Combine(directory, blob.Name); + var blobClient = container.GetBlobClient(blobItem.Name); + string filename = Path.Combine(directory, blobItem.Name); - downloadTasks.Add(blob.DownloadToFileAsync(path, FileMode.Create)); + downloadTasks.Add(blobClient.DownloadToAsync(filename)); } + // Get the continuation token and loop until it is empty. + continuationToken = blobPage.ContinuationToken; } - continuationToken = segment.ContinuationToken; - } - while (continuationToken != null); + } while (continuationToken != ""); await Task.WhenAll(downloadTasks); diff --git a/AMSV3Tutorials/UploadEncodeAndStreamFiles/UploadEncodeAndStreamFiles.csproj b/AMSV3Tutorials/UploadEncodeAndStreamFiles/UploadEncodeAndStreamFiles.csproj index 5fe51b5..d846085 100644 --- a/AMSV3Tutorials/UploadEncodeAndStreamFiles/UploadEncodeAndStreamFiles.csproj +++ b/AMSV3Tutorials/UploadEncodeAndStreamFiles/UploadEncodeAndStreamFiles.csproj @@ -12,11 +12,11 @@ - - - - - + + + + +