Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xpouyat committed Nov 17, 2020
2 parents 8e44a83 + 0807545 commit 50704e2
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 104 deletions.
10 changes: 5 additions & 5 deletions AMSV3Tutorials/AnalyzeVideos/AnalyzeVideos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Media" Version="2.0.5" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.6" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.7.0" />
<PackageReference Include="Microsoft.Azure.Management.Media" Version="3.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.4.1" />
</ItemGroup>

Expand Down
39 changes: 18 additions & 21 deletions AMSV3Tutorials/AnalyzeVideos/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -233,11 +233,11 @@ private static async Task<Asset> 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;
}
Expand Down Expand Up @@ -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<Task> downloadTasks = new List<Task>();

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<BlobItem> 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);

Expand Down
14 changes: 7 additions & 7 deletions AMSV3Tutorials/EncryptWithAES/EncryptWithAES.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.2.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.7.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt " Version="5.3.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.7.1" />
<PackageReference Include="Microsoft.Azure.Management.Media" Version="2.0.5" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.6" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.8.0" />
<PackageReference Include="Microsoft.Azure.Management.Media" Version="3.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.4.1" />
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
</ItemGroup>
Expand All @@ -31,7 +31,7 @@


<ItemGroup>
<PackageReference Update="System.IdentityModel.Tokens.Jwt" Version="6.7.1" />
<PackageReference Update="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
</ItemGroup>

</Project>
31 changes: 13 additions & 18 deletions AMSV3Tutorials/EncryptWithAES/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Task> downloadTasks = new List<Task>();

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<BlobItem> 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);

Expand Down
14 changes: 7 additions & 7 deletions AMSV3Tutorials/EncryptWithDRM/EncryptWithDRM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.2.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.7.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt " Version="5.3.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.7.1" />
<PackageReference Include="Microsoft.Azure.Management.Media" Version="2.0.5" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.6" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.8.0" />
<PackageReference Include="Microsoft.Azure.Management.Media" Version="3.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.4.1" />
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
</ItemGroup>
Expand All @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="System.IdentityModel.Tokens.Jwt" Version="6.7.1" />
<PackageReference Update="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
</ItemGroup>

</Project>
30 changes: 13 additions & 17 deletions AMSV3Tutorials/EncryptWithDRM/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Task> downloadTasks = new List<Task>();

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<BlobItem> 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);

Expand Down
44 changes: 20 additions & 24 deletions AMSV3Tutorials/UploadEncodeAndStreamFiles/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}");
Expand Down Expand Up @@ -193,11 +193,11 @@ private static async Task<Asset> 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;
}
Expand Down Expand Up @@ -226,9 +226,9 @@ private static async Task<Asset> 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);
Expand Down Expand Up @@ -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<Task> downloadTasks = new List<Task>();

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<BlobItem> 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);

Expand Down
Loading

0 comments on commit 50704e2

Please sign in to comment.