コード例 #1
0
 public static IActionResult TestDbConnection(
     [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req,
     ILogger log)
 {
     try
     {
         return(new OkObjectResult(KeyVault.GetSecret("DocumentDbConnStringId")));
     }
     catch (Exception e)
     {
         return(new BadRequestObjectResult(e.Message));
     }
 }
コード例 #2
0
        private static DocumentClient GetDocumentClient()
        {
            if (documentClient == null)
            {
#if DEBUG
                var connectionString = "AccountEndpoint=https://kardastidev.documents.azure.com:443/;AccountKey=YbIfGnsaDDdLRIj7uaE7ClZq1jXka37Xv4bxcJXzeM8Mp8k0fVh3l4VkHd8bCVs3LifJxRIRru9HPYqSv5mdsg==;";
#else
                var connectionString = KeyVault.GetSecret("DocumentDbConnStringId");
#endif
                documentClient = DocumentClientEx.GetDocumentClient(connectionString);
            }
            return(documentClient);
        }
コード例 #3
0
        public static CloudBlobContainer GetContainer(string containerName, out CloudBlobContainer container)
        {
#if DEBUG
            var connectionString = "DefaultEndpointsProtocol=https;AccountName=kardastiitemphotosdev;AccountKey=Bjdc5Ap2jdZZ844Cttxx7B/VfJei8U2Qac+Hc4Q30prf1gaWWX9GZ25v8SsDoeA/ziatBSk+QtB5Wrqcy+PgXA==;EndpointSuffix=core.windows.net";
#else
            var connectionString = KeyVault.GetSecret("ItemImagesConnStringId");
#endif
            var connectionParts    = connectionString.Split(new[] { "DefaultEndpointsProtocol=", "AccountName=", "AccountKey=", "EndpointSuffix" }, 4, StringSplitOptions.RemoveEmptyEntries);
            var accountName        = connectionParts[1].Trim(new[] { ';' });
            var accountKey         = connectionParts[2].Trim(new[] { ';' });
            var storageCredentials = new StorageCredentials(accountName, accountKey);
            var storageAccount     = new CloudStorageAccount(storageCredentials, true);
            var blobClient         = storageAccount.CreateCloudBlobClient();
            container = blobClient.GetContainerReference(containerName);
            return(container);
        }