本文整理汇总了C#中CloudStorageAccount类的典型用法代码示例。如果您正苦于以下问题:C# CloudStorageAccount类的具体用法?C# CloudStorageAccount怎么用?C# CloudStorageAccount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudStorageAccount类属于命名空间,在下文中一共展示了CloudStorageAccount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NDIAzureTableController
static NDIAzureTableController()
{
_storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
_tableClient = _storageAccount.CreateCloudTableClient();
_table = _tableClient.GetTableReference("ndiparams");
_retrieveOperation = TableOperation.Retrieve("VidParams", "LastVideo");
}
示例2: TProduct
public TProduct(string affiliate, string code, int qty, bool force_lookup = false)
{
ProductCode = code;
Qty = qty;
cloud = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("AbundaStorage"));
client = cloud.CreateCloudTableClient();
products = client.GetTableReference("Products");
products.CreateIfNotExists();
using (var context = new DataBaseDataContext())
{
var aff = (from ev in context.Affiliates
where ev.code == affiliate
select ev).FirstOrDefault();
merchantID = aff.MerchantID;
marketplaceID = aff.MarketPlaceID;
secretKey = aff.SecretKey;
accessKey = aff.AccessKey;
}
var amzResults = PerformAmazonLookup();
}
示例3: TableStorageOperations
public TableStorageOperations()
{
//var cloudStorageConnectionString =
// CloudConfigurationManager.GetSetting(CloudConfigurationName.DefaultStorageConnectionString);
var cloudStorageConnectionString =
ConfigurationManager.ConnectionStrings[CloudConfigurationName.DefaultStorageConnectionString].ConnectionString;
_cloudStorageAccount = CloudStorageAccount.Parse(cloudStorageConnectionString);
示例4: Upload
public Uri Upload(SubscriptionCloudCredentials credentials, string storageAccountName, string packageFile, string uploadedFileName)
{
var cloudStorage =
new CloudStorageAccount(new StorageCredentials(storageAccountName, GetStorageAccountPrimaryKey(credentials, storageAccountName)), true);
var blobClient = cloudStorage.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(OctopusPackagesContainerName);
container.CreateIfNotExists();
var permission = container.GetPermissions();
permission.PublicAccess = BlobContainerPublicAccessType.Off;
container.SetPermissions(permission);
var fileInfo = new FileInfo(packageFile);
var packageBlob = GetUniqueBlobName(uploadedFileName, fileInfo, container);
if (packageBlob.Exists())
{
Log.VerboseFormat("A blob named {0} already exists with the same length, so it will be used instead of uploading the new package.",
packageBlob.Name);
return packageBlob.Uri;
}
UploadBlobInChunks(fileInfo, packageBlob, blobClient);
Log.Info("Package upload complete");
return packageBlob.Uri;
}
示例5: Initialise
/// <summary>
/// Occurs when a storage provider operation has completed.
/// </summary>
//public event EventHandler<StorageProviderEventArgs> StorageProviderOperationCompleted;
#endregion
// Initialiser method
private void Initialise(string storageAccount, string containerName)
{
if (String.IsNullOrEmpty(containerName))
throw new ArgumentException("You must provide the base Container Name", "containerName");
ContainerName = containerName;
_account = CloudStorageAccount.Parse(storageAccount);
_blobClient = _account.CreateCloudBlobClient();
_container = _blobClient.GetContainerReference(ContainerName);
try
{
_container.FetchAttributes();
}
catch (StorageException)
{
Trace.WriteLine(string.Format("Create new container: {0}", ContainerName), "Information");
_container.Create();
// set new container's permissions
// Create a permission policy to set the public access setting for the container.
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// The public access setting explicitly specifies that the container is private,
// so that it can't be accessed anonymously.
containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;
//Set the permission policy on the container.
_container.SetPermissions(containerPermissions);
}
}
示例6: InitializeCors
private void InitializeCors()
{
var tableServiceProperties = new ServiceProperties();
var tableClient =
new CloudStorageAccount(
new StorageCredentials(
CloudConfigurationManager.GetSetting("storageAccountName"),
CloudConfigurationManager.GetSetting("storageAccountKey")),
true).CreateCloudTableClient();
tableServiceProperties.HourMetrics = null;
tableServiceProperties.MinuteMetrics = null;
tableServiceProperties.Logging = null;
tableServiceProperties.Cors = new CorsProperties();
tableServiceProperties.Cors.CorsRules.Add(new CorsRule()
{
AllowedHeaders = new List<string>() { "*" },
AllowedMethods = CorsHttpMethods.Get | CorsHttpMethods.Head ,
//AllowedOrigins = new List<string>() { "http://ercenkbike.azurewebsites.net/" },
AllowedOrigins = new List<string>() { "*" },
ExposedHeaders = new List<string>() { "*" },
MaxAgeInSeconds = 1800 // 30 minutes
});
tableClient.SetServiceProperties(tableServiceProperties);
}
示例7: Initialize
protected override void Initialize(HttpControllerContext controllerContext)
{
base.Initialize(controllerContext);
storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
var tableClient = storageAccount.CreateCloudTableClient();
table = tableClient.GetTableReference("people");
}
示例8: CreateCloudStorageContainer
public CloudStorageContainer CreateCloudStorageContainer(CloudStorageAccount account, Guid publicKey, string alias, string containerName, string description)
{
if (account == null)
throw new NullReferenceException("DefaultCloudStorageAccount cannot be null.");
Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = CreateInternalAzureCloudStorageAccount(account.AccountName, account.AccountKey);
Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer container = blobClient.GetContainerReference(containerName);
container.Create();
container.SetPermissions(new Microsoft.WindowsAzure.Storage.Blob.BlobContainerPermissions {
PublicAccess = Microsoft.WindowsAzure.Storage.Blob.BlobContainerPublicAccessType.Off
});
// var containers = blobClient.ListContainers();
CloudStorageContainer csContainer = this.context.CloudStorageContainers.Add( new CloudStorageContainer {
CloudStorageAccountId = account.CloudStorageAccountId,
PublicKey = publicKey,
ProviderKey = containerName,
ContainerName = containerName,
Alias = alias,
Description = description
});
context.SaveChanges();
return csContainer;
}
示例9: DeleteBlob
public static bool DeleteBlob(string blobName)
{
//http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/#delete-blobs
string accountKey = "",
accountName = "",
blobContainer = "";
try
{
CloudStorageAccount storageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(accountName, accountKey), true);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference(blobContainer);
// Retrieve reference to a blob named "myblob.txt".
CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);
// Delete the blob.
blockBlob.Delete();
}
catch (Exception)
{
return false;
}
return true;
}
示例10: Patch
private CloudStorageAccount Patch(CloudStorageAccount account)
{
ServicePointManager.FindServicePoint(account.BlobEndpoint).UseNagleAlgorithm = false;
ServicePointManager.FindServicePoint(account.TableEndpoint).UseNagleAlgorithm = false;
ServicePointManager.FindServicePoint(account.QueueEndpoint).UseNagleAlgorithm = false;
return account;
}
示例11: GetCurrentStorageAccount
public CloudStorageAccount GetCurrentStorageAccount(IServiceManagement channel)
{
if (String.IsNullOrEmpty(CurrentStorageAccount))
{
return null;
}
if (_currentStorageAccount != null)
{
return _currentStorageAccount;
}
CloudStorageAccount currentStorage = null;
using (new OperationContextScope((IContextChannel)channel))
{
var storageService = channel.GetStorageService(SubscriptionId, CurrentStorageAccount);
var storageServiceKeys = channel.GetStorageKeys(SubscriptionId, CurrentStorageAccount);
if (storageService != null && storageServiceKeys != null)
{
string connectionString = General.BuildConnectionString("https", storageService.ServiceName, storageServiceKeys.StorageServiceKeys.Primary, storageService.StorageServiceProperties.Endpoints[0].Replace("http://", "https://"), storageService.StorageServiceProperties.Endpoints[2].Replace("http://", "https://"), storageService.StorageServiceProperties.Endpoints[1].Replace("http://", "https://"));
currentStorage = CloudStorageAccount.Parse(connectionString);
}
}
_currentStorageAccount = currentStorage;
return currentStorage;
}
示例12: PurgeAllAsync
/// <summary>
/// A helper method that purges all of blob storage.
/// </summary>
/// <param name="azureAccount">The Azure account to clear out.</param>
/// <returns>A task representing the asynchronous operation.</returns>
private static async Task PurgeAllAsync(CloudStorageAccount azureAccount) {
Requires.NotNull(azureAccount, "azureAccount");
var blobClient = azureAccount.CreateCloudBlobClient();
foreach (var container in blobClient.ListContainers()) {
if (container.Name != "wad-control-container") {
Console.WriteLine("\nContainer: {0}", container.Name);
if (container.Name.StartsWith("unittests")) {
container.Delete();
} else {
var blobs = await container.ListBlobsSegmentedAsync(
container.Name,
useFlatBlobListing: true,
pageSize: 50,
details: BlobListingDetails.Metadata,
options: new BlobRequestOptions(),
operationContext: null);
foreach (var blob in blobs.Cast<ICloudBlob>()) {
Console.WriteLine("\tBlob: {0} {1}", blob.Uri, blob.Metadata["DeleteAfter"]);
}
await Task.WhenAll(blobs.Cast<ICloudBlob>().Select(b => b.DeleteAsync()));
}
}
}
}
示例13: MakeQueue
private static CloudQueue MakeQueue(CloudStorageAccount account)
{
var client = account.CreateCloudQueueClient();
client.RetryPolicy = new ExponentialRetry(new TimeSpan(0, 0, 0, 2), 10);
return client.GetQueueReference(QueueName);
}
示例14: SensorAccess
public SensorAccess()
{
credentials = new StorageCredentials(_accountName, _key);
storageAccount = new CloudStorageAccount(credentials, true);
tableClient = storageAccount.CreateCloudTableClient();
table = tableClient.GetTableReference("AccelerometerTable");
}
示例15: TableStorageAppender
/// <summary>
/// Constructs a new instance of the TableStorageAppender with default settings.
/// </summary>
/// <param name="storageAccount">The storage account to use</param>
public TableStorageAppender(CloudStorageAccount storageAccount)
{
StorageAccount = storageAccount;
TableName = "WADLogsTable";
TransferIntervalInMinutes = 5;
LogmarkerIntervalInMinutes = 30;
}