55using Azure . Storage . Blobs ;
66using Microsoft . Azure . Cosmos ;
77using Microsoft . Extensions . Configuration ;
8+ using Azure . Identity ;
9+ using System ;
810
911namespace APIViewWeb . MiddleWare
1012{
@@ -18,19 +20,20 @@ public UITestsMiddleWare(RequestDelegate next)
1820
1921 public async Task InvokeAsync ( HttpContext httpContext , IConfiguration config )
2022 {
21- var cosmosClient = new CosmosClient ( config [ "Cosmos:ConnectionString" ] ) ;
22- var dataBaseResponse = await cosmosClient . CreateDatabaseIfNotExistsAsync ( "APIView" ) ;
23+ var cosmosClient = new CosmosClient ( config [ "CosmosEndpoint" ] , new DefaultAzureCredential ( ) ) ;
24+ var dataBaseResponse = await cosmosClient . CreateDatabaseIfNotExistsAsync ( config [ "CosmosDBName" ] ) ;
2325 _ = await dataBaseResponse . Database . CreateContainerIfNotExistsAsync ( "Reviews" , "/id" ) ;
2426 _ = await dataBaseResponse . Database . CreateContainerIfNotExistsAsync ( "Comments" , "/ReviewId" ) ;
2527 _ = await dataBaseResponse . Database . CreateContainerIfNotExistsAsync ( "Profiles" , "/id" ) ;
2628 _ = await dataBaseResponse . Database . CreateContainerIfNotExistsAsync ( "PullRequests" , "/PullRequestNumber" ) ;
2729 _ = await dataBaseResponse . Database . CreateContainerIfNotExistsAsync ( "UsageSamples" , "/ReviewId" ) ;
2830 _ = await dataBaseResponse . Database . CreateContainerIfNotExistsAsync ( "UserPreference" , "/ReviewId" ) ;
2931
30- var blobCodeFileContainerClient = new BlobContainerClient ( config [ "Blob:ConnectionString" ] , "codefiles" ) ;
31- var blobOriginalContainerClient = new BlobContainerClient ( config [ "Blob:ConnectionString" ] , "originals" ) ;
32- var blobUsageSampleRepository = new BlobContainerClient ( config [ "Blob:ConnectionString" ] , "usagesamples" ) ;
33- var blobCommentsRepository = new BlobContainerClient ( config [ "Blob:ConnectionString" ] , "comments" ) ;
32+ var blobServiceClient = new BlobServiceClient ( new Uri ( config [ "StorageAccountUrl" ] ) , new DefaultAzureCredential ( ) ) ;
33+ var blobCodeFileContainerClient = blobServiceClient . GetBlobContainerClient ( "codefiles" ) ;
34+ var blobOriginalContainerClient = blobServiceClient . GetBlobContainerClient ( "originals" ) ;
35+ var blobUsageSampleRepository = blobServiceClient . GetBlobContainerClient ( "usagesamples" ) ;
36+ var blobCommentsRepository = blobServiceClient . GetBlobContainerClient ( "comments" ) ;
3437 _ = await blobCodeFileContainerClient . CreateIfNotExistsAsync ( PublicAccessType . BlobContainer ) ;
3538 _ = await blobOriginalContainerClient . CreateIfNotExistsAsync ( PublicAccessType . BlobContainer ) ;
3639 _ = await blobUsageSampleRepository . CreateIfNotExistsAsync ( PublicAccessType . BlobContainer ) ;
0 commit comments