本文整理汇总了C#中Microsoft.WindowsAzure.CloudStorageAccount类的典型用法代码示例。如果您正苦于以下问题:C# CloudStorageAccount类的具体用法?C# CloudStorageAccount怎么用?C# CloudStorageAccount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudStorageAccount类属于Microsoft.WindowsAzure命名空间,在下文中一共展示了CloudStorageAccount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTableStream
private Stream GetTableStream(CloudStorageAccount account, string tableName, string query)
{
var requestUri = new StringBuilder();
requestUri.AppendFormat("{0}{1}()", account.TableEndpoint.ToString(), tableName);
if (String.IsNullOrWhiteSpace(query))
{
requestUri.AppendFormat("?{0}", query);
}
// create Http Request
var request = (HttpWebRequest)HttpWebRequest.Create(requestUri.ToString());
// For requests using the $select query option, the request must be made using version 2011-08-18
// or newer. In addition, the DataServiceVersion and MaxDataServiceVersion headers must be set
// to 2.0.
// http://msdn.microsoft.com/en-us/library/dd179421.aspx
request.Headers.Add("x-ms-version", "2011-08-18");
request.Headers.Add("MaxDataServiceVersion", "2.0");
// signs request using the specified credentials under the Shared Key Lite authentication
account.Credentials.SignRequestLite(request);
var response = (HttpWebResponse)request.GetResponse();
// get stream from response with response encoding
var sr = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(response.CharacterSet));
return sr.BaseStream;
}
示例2: PushServiceTokenRepository
public PushServiceTokenRepository()
{
storage = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
client = storage.CreateCloudTableClient();
client.CreateTableIfNotExist(TableName);
context = client.GetDataServiceContext();
}
示例3: Storage
public Storage(CloudStorageAccount account)
{
this.account = account;
fileStorage = account.CreateCloudBlobClient();
/* Initialize file container */
container = fileStorage.GetContainerReference(filesContainer);
container.CreateIfNotExist();
var permissions = container.GetPermissions();
/* Full permissions. From MSDN, Container-level public access. Anonymous clients can
* read blob content and metadata and container metadata, and can list the blobs within the container.
*
* Other alternatives are Blob (can read content but not metadata) and Off (no
* anonymous access).
*/
// permissions.PublicAccess = BlobContainerPublicAccessType.Container;
permissions.PublicAccess = BlobContainerPublicAccessType.Off;
permissions.SharedAccessPolicies.Remove("basic");
permissions.SharedAccessPolicies.Add("basic", new SharedAccessPolicy()
{
});
container.SetPermissions(permissions);
/* Initialize table (for file metadata) */
CloudTableClient.CreateTablesFromModel(
typeof(FileDataContext),
account.TableEndpoint.AbsoluteUri,
account.Credentials);
}
示例4: AzureEventStore
public AzureEventStore(CloudStorageAccount storageAccount)
{
_account = storageAccount;
_tableClient = _account.CreateCloudTableClient();
InitializeStorage();
}
示例5: InitializeCloudStorage
public static void InitializeCloudStorage(CloudStorageAccount account)
{
CloudTableClient cloudTableClient = account.CreateCloudTableClient();
CloudQueueClient cloudQueueClient = account.CreateCloudQueueClient();
CreateUserPrivilegeTable(cloudTableClient);
}
示例6: 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;
}
示例7: AzureStorageProvider
public AzureStorageProvider(CloudStorageAccount storageAccount)
{
cloudStorageAccount = storageAccount;
// Create the blob client
blobStorage = cloudStorageAccount.CreateCloudBlobClient();
}
示例8: Install
public void Install(IPaths paths, CloudStorageAccount storageAccount, int port, ICloudDriveManager cloudDriveManager)
{
Trace.TraceInformation("Installing Neo4j server.");
DownloadJava(paths, storageAccount);
UnzipJava(paths);
DownloadNeo4j(paths, storageAccount);
UnzipNeo4j(paths);
try
{
// try to mount cloud drive
MountDatabase(paths, cloudDriveManager);
SetServerDbPathConfig(paths, port);
}
catch (Exception ex)
{
Trace.TraceError("Drive Mounting Error: " + ex.Message);
}
SetServerPortAndUrlConfig(paths, port);
SetJavaPath(paths);
CopyConfigurationFilesToLogsDirectory(paths);
ClearLogDirectory(paths);
Trace.TraceInformation("Neo4j server installed.");
}
示例9: AzureStorageServiceBase
static AzureStorageServiceBase()
{
if (RoleEnvironment.IsEmulated)
storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
else
storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(StorageConnectionString));
}
示例10: CopyBlockBlob
/// <summary>
/// Copies a blob from one account and container to another.
/// </summary>
/// <param name="copyBlockBlobSettings">A <see cref="CopyBlockBlobSettings"/>.</param>
public static void CopyBlockBlob(CopyBlockBlobSettings copyBlockBlobSettings)
{
Contract.Requires(copyBlockBlobSettings != null, "The copy block blob settings cannot be null.");
var sourceStorageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(copyBlockBlobSettings.BlobStorageSource, copyBlockBlobSettings.BlobStorageSourceKey), copyBlockBlobSettings.UseHttps);
var sourceClient = sourceStorageAccount.CreateCloudBlobClient();
var destinationStorageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(copyBlockBlobSettings.BlobStorageDestination, copyBlockBlobSettings.BlobStorageDestinationKey), copyBlockBlobSettings.UseHttps);
var destinationClient = destinationStorageAccount.CreateCloudBlobClient();
var destinationContainer = destinationClient.GetContainerReference(copyBlockBlobSettings.DestinationContainerName);
try
{
destinationContainer.CreateIfNotExist();
}
catch
{
// do nothing, create if not exists blows up if it already exists... nice.
}
var sourceBlob = sourceClient.GetBlockBlobReference(copyBlockBlobSettings.BlobSourcePath);
sourceBlob.FetchAttributes();
CloudBlob destinationBlob = destinationClient.GetBlockBlobReference(copyBlockBlobSettings.BlobDestinationPath);
destinationBlob.StartCopyFromBlob(sourceBlob.Uri);
MonitorCopy(destinationBlob.Container);
}
示例11: WorkerRoleLoader
public WorkerRoleLoader()
{
this.LastModified = DateTime.MinValue;
this.storageAccount = CloudStorageAccount.FromConfigurationSetting(DataConfigurationKey);
this.blobStorage = storageAccount.CreateCloudBlobClient();
}
示例12: InitializeStorage
internal static bool InitializeStorage()
{
try
{
// 仅为测试目的,如果我们不在计算仿真程序中运行该服务,我们始终使用 dev 存储.
if (RoleEnvironment.IsAvailable)
{
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
{
configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
});
StorageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
}
else
{
StorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
}
CloudBlobClient blobClient = new CloudBlobClient(StorageAccount.BlobEndpoint, StorageAccount.Credentials);
CloudBlobContainer container = blobClient.GetContainerReference("videostories");
container.CreateIfNotExist();
CloudQueueClient queueClient = new CloudQueueClient(StorageAccount.QueueEndpoint, StorageAccount.Credentials);
CloudQueue queue = queueClient.GetQueueReference("videostories");
queue.CreateIfNotExist();
CloudTableClient tableClient = new CloudTableClient(StorageAccount.TableEndpoint.AbsoluteUri, StorageAccount.Credentials);
tableClient.CreateTableIfNotExist("Stories");
return true;
}
catch (Exception ex)
{
Trace.Write("错误初始化存储: " + ex.Message, "Error");
return false;
}
}
示例13: AddAilmentDetails
//ADD AILMENT DETAILS
public void AddAilmentDetails(AilmentDetails AilData)
{
#if DEBUG
account = CloudStorageAccount.DevelopmentStorageAccount;
#else
account = new CloudStorageAccount(accountAndKey, true);
#endif
client = account.CreateCloudTableClient();
client.CreateTableIfNotExist("PatientDetails");
tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials);
AilmentDetails x = new AilmentDetails();
x.AttendingPhysician = AilData.AttendingPhysician;
x.Diagnosis = AilData.Diagnosis;
x.DiagnosisID = AilData.DiagnosisID;
x.GeneralPhysician = AilData.GeneralPhysician;
x.Hospital = AilData.Hospital;
x.Lab_Pathology = AilData.Lab_Pathology;
x.Lab_Physical = AilData.Lab_Physical;
x.Lab_Radiology = AilData.Lab_Physical;
x.Medication = AilData.Medication;
x.PatientIDLinkRowKey = AilData.PatientIDLinkRowKey;
x.ProgressNotes = AilData.ProgressNotes;
x.Symptoms = AilData.Symptoms;
x.TimeIn = AilData.TimeIn;
x.TimeOut = AilData.TimeOut;
x.Treatment = AilData.Treatment;
x.AilmentDetailRowKey = AilData.AilmentDetailRowKey;
tableContext.AddObject("PatientDetails", x);
tableContext.SaveChanges();
}
示例14: OnInitialize
private void OnInitialize()
{
var selfInstance = InstanceEnumerator.GetSelf();
cloudStorageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(ConfigurationSettingsKeys.StorageConnectionString));
log.Info("Storage account selected: {0}",cloudStorageAccount.BlobEndpoint);
cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
log.Info("Storage client created");
var containerName = ConfigurationProvider.GetSetting(ConfigurationSettingsKeys.StorageContainerName,"ravendb");
// In order to force a connection we just enumerate all available containers:
var availableContainers = cloudBlobClient.ListContainers().ToArray();
foreach (var container in availableContainers)
{
log.Info("Available container: {0}",container.Name);
}
if (!availableContainers.Any(c => c.Name.Equals(containerName)))
{
log.Info("Container {0} does not exist, creating",containerName);
// Container does not exist:
cloudBlobClient.GetContainerReference(containerName).Create();
}
cloudBlobContainer = cloudBlobClient.GetContainerReference(containerName);
log.Info("Container {0} selected",cloudBlobContainer.Name);
localCache = RoleEnvironment.GetLocalResource(ConfigurationSettingsKeys.StorageCacheResource);
log.Info("Cache resource retrieved: {0}, path: {1}",localCache.Name,localCache.RootPath);
CloudDrive.InitializeCache(localCache.RootPath, localCache.MaximumSizeInMegabytes);
log.Info("Cache initialized: {0} mb",localCache.MaximumSizeInMegabytes);
var driveName = string.Format("{0}{1}.vhd", selfInstance.RoleName, selfInstance.RoleInstanceIndex).ToLowerInvariant();
log.Info("Virtual drive name: {0}",driveName);
var pageBlob = cloudBlobContainer.GetPageBlobReference(driveName);
log.Info("Virtual drive blob: {0}",pageBlob.Uri);
cloudDrive = cloudStorageAccount.CreateCloudDrive(pageBlob.Uri.ToString());
log.Info("Virtual drive created: {0}",cloudDrive.Uri);
var storageSize = ConfigurationProvider.GetSetting(ConfigurationSettingsKeys.StorageSizeInMb, 50000);
log.Info("Storage size: {0} mb",storageSize);
cloudDrive.CreateIfNotExist(storageSize);
log.Info("Virtual drive initialized: {0}",cloudDrive.Uri);
var mountedDirectoryPath = cloudDrive.Mount(storageSize, DriveMountOptions.None);
log.Info("Virtual drive mounted at: {0}",mountedDirectoryPath);
mountedDirectory = new DirectoryInfo(mountedDirectoryPath);
log.Info("Executing drive benchmark for: {0}",mountedDirectoryPath);
ExecuteBenchmarks(mountedDirectory,storageSize);
log.Info("Storage initialization succeeded");
}
示例15: given_blob_storage
public given_blob_storage()
{
var settings = InfrastructureSettings.Read("Settings.xml").BlobStorage;
this.account = CloudStorageAccount.Parse(settings.ConnectionString);
this.rootContainerName = Guid.NewGuid().ToString();
this.sut = new CloudBlobStorage(account, this.rootContainerName);
}