Ejemplo n.º 1
0
        public static async Task CreateCosmosResourcesIfNotExists(this IAzure azure, ILogger logger, AppyCosmosDbParameters parameters)
        {
            var cosmosAccount = await azure.CreateCosmosAccountIfNotExists(logger, parameters);

            var cosmosKeys     = cosmosAccount.ListKeys();
            var masterKey      = cosmosKeys.PrimaryMasterKey;
            var endPoint       = cosmosAccount.DocumentEndpoint;
            var documentClient = CreateCosmosDocumentClient(masterKey, endPoint);

            await documentClient.CreateCosmosDatabaseIfNotExists(logger, parameters.DatabaseId);

            foreach (var collectionId in parameters.CollectionIds)
            {
                await documentClient.CreateCosmosDbAndCollectionIfNotExists(logger, parameters.DatabaseId, collectionId);
            }
        }