Esempio n. 1
0
        static public CloudTableClient GetCloudTableClient(AzureStorageConfig _storageConfig)
        {
            // Create cloudstorage account by passing the storageconnectionstring
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(_storageConfig.ConnectionString);

            // Create the blob client.
            CloudTableClient client = storageAccount.CreateCloudTableClient();

            return(client);
        }
Esempio n. 2
0
        static public string UploadLog(AzureStorageConfig _storageConfig, string content)
        {
            string log = "";

            CloudBlobContainer container = GetBlobContainer(_storageConfig);
            CloudBlockBlob     blob      = container.GetBlockBlobReference(string.Format("{0}_log.txt", _storageConfig.Container));

            try
            {
                blob.UploadTextAsync(content).Wait();
            }
            catch { };
            return(log);
        }
Esempio n. 3
0
        public string DownloadLog(AzureStorageConfig _storageConfig)
        {
            string log = "";

            CloudBlobContainer container = GetBlobContainer(_storageConfig);
            CloudBlockBlob     blob      = container.GetBlockBlobReference(string.Format("{0}_log.txt", _storageConfig.Container));

            try
            {
                log = blob.DownloadTextAsync().Result;
            }
            catch { };
            return(log);
        }
Esempio n. 4
0
        static public CloudBlobContainer GetBlobContainer(AzureStorageConfig _storageConfig)
        {
            // Create cloudstorage account by passing the storageconnectionstring
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(_storageConfig.ConnectionString);

            // Create the blob client.
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            // Get reference to the blob container by passing the name by reading the value from the configuration (appsettings.json)
            CloudBlobContainer container = blobClient.GetContainerReference(_storageConfig.Container);

            container.CreateIfNotExistsAsync();

            return(container);
        }