本文整理汇总了C#中Microsoft.WindowsAzure.Storage.CloudStorageAccount类的典型用法代码示例。如果您正苦于以下问题:C# CloudStorageAccount类的具体用法?C# CloudStorageAccount怎么用?C# CloudStorageAccount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudStorageAccount类属于Microsoft.WindowsAzure.Storage命名空间,在下文中一共展示了CloudStorageAccount类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Tracker
public Tracker(string accountName, string keyValue)
{
_applicationId = IdUtil.ApplicationId();
_deviceId = IdUtil.DeviceId();
_anid = IdUtil.GetAnidFromOs();
_appTitle = IdUtil.ApplicationName();
_adsRefreshRate = 3;
_pubCenterAdsId = new List<string>();
_adsReady = false;
// Due to Disallowed key in RowKey, /, \, #, ? needs to be removed
// And excel cannot allow "=" at the beginning
foreach (var s in _invalidRowKeyChar) {
_deviceId = _deviceId.Replace(s, string.Empty);
if (_deviceId.Substring(0, 1) == "=") {
_deviceId = "x" + _deviceId;
}
}
GetAdAssemblyVersion();
RefreshIpInfo();
_storageCredentials = new StorageCredentials(accountName, keyValue);
_storageAccount = new CloudStorageAccount(_storageCredentials, false);
_tableClient = _storageAccount.CreateCloudTableClient();
EnsureTablesCreated();
}
开发者ID:NBitionDevelopment,项目名称:WindowsPhonePhotoHuntAnimal,代码行数:28,代码来源:Tracker.cs
示例2: AzureService
public AzureService(string account, string azureKey, string blobUri)
{
_account = account;
var storageAccount = new CloudStorageAccount(new StorageCredentials(account, azureKey), new Uri(blobUri),
null, null);
_client = storageAccount.CreateCloudBlobClient();
}
开发者ID:jbdk,项目名称:SigningService,代码行数:7,代码来源:AzureService.cs
示例3: StorageTableAccessor
public StorageTableAccessor(CloudStorageAccount storageAccount)
{
CloudTableClient tableClient = new CloudTableClient(storageAccount.TableStorageUri, storageAccount.Credentials);
this.table = tableClient.GetTableReference(messageTableName);
this.table.CreateIfNotExists();
ReadFirstEntry();
}
开发者ID:theadriangreen,项目名称:azure-sdk-for-net,代码行数:7,代码来源:StorageTableAccessor.cs
示例4: InitStorage
private static void InitStorage()
{
var credentials = new StorageCredentials(AppKeys.Storage_Account_Name, AppKeys.PrimaryAccessKey);
var storageAccount = new CloudStorageAccount(credentials, true);
var blobClient = storageAccount.CreateCloudBlobClient();
imagesContainer = blobClient.GetContainerReference("images");
}
开发者ID:antataiv,项目名称:ASP.Net-Photo-Contest-Web-Application,代码行数:7,代码来源:BaseController.cs
示例5: Main
static void Main(string[] args)
{
try
{
//hace la cuenta
StorageCredentials creds = new StorageCredentials(accountName, accountKey);
CloudStorageAccount account = new CloudStorageAccount(creds, useHttps: true);
//crea el cliente
CloudBlobClient client = account.CreateCloudBlobClient();
//crae el contenedor
CloudBlobContainer sampleContainer = client.GetContainerReference("music");
sampleContainer.CreateIfNotExists();
//
CloudBlockBlob blob = sampleContainer.GetBlockBlobReference("9.mp3");
using (System.IO.Stream file = System.IO.File.OpenRead("C:\\Users\\Andres\\Downloads\\9.mp3"))
{
blob.UploadFromStream(file);
}
/*CloudBlockBlob blob = sampleContainer.GetBlockBlobReference("APictureFile.jpg");
using (Stream outputFile = new FileStream("Downloaded.jpg", FileMode.Create))
{
blob.DownloadToStream(outputFile);
}*/
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Console.Read();
}
开发者ID:mefistobases2015,项目名称:Odyssey,代码行数:33,代码来源:Program.cs
示例6: StorageHelper
public StorageHelper()
{
var storageCred = new StorageCredentials(AppSettings.StorageAccountName, AppSettings.StorageAccountKey);
storageAccount = new CloudStorageAccount(storageCred, true);
configureCors(storageAccount);
}
开发者ID:cephalin,项目名称:ContosoMoments,代码行数:7,代码来源:StorageHelper.cs
示例7: uploadSong
public bool uploadSong(int song_id, string song_path)
{
bool flag = false;
//hace la cuenta
StorageCredentials creds = new StorageCredentials(accountName, accountKey);
CloudStorageAccount account = new CloudStorageAccount(creds, useHttps: true);
//crea el cliente
CloudBlobClient client = account.CreateCloudBlobClient();
//crae el contenedor
CloudBlobContainer container = client.GetContainerReference("music");
container.CreateIfNotExists();
//
CloudBlockBlob blob = container.GetBlockBlobReference(song_id.ToString() + ".mp3");
using (System.IO.Stream file = System.IO.File.OpenRead(song_path))
{
try
{
blob.UploadFromStream(file);
flag = true;
}
catch (Exception e)
{
Console.WriteLine(e);
flag = false;
}
}
return flag;
}
开发者ID:mefistobases2015,项目名称:OdysseyClient,代码行数:34,代码来源:BlobManager.cs
示例8: when_writting_to_a_pageBlob_all_data_is_correctly_retrieved
public void when_writting_to_a_pageBlob_all_data_is_correctly_retrieved()
{
var azureAccount = new CloudStorageAccount(new StorageCredentials("valeriob", "2SzgTAaG11U0M1gQ19SNus/vv1f0efwYOwZHL1w9YhTKEYsU1ul+s/ke92DOE1wIeCKYz5CuaowtDceUvZW2Rw=="), true);
var blobClient = azureAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("test");
container.CreateIfNotExists();
var blob = container.GetPageBlobReference(Guid.NewGuid()+"");
var helper = new AzurePageBlob(blob);
//helper.Create_if_does_not_exists();
helper.OpenAsync().Wait();
var output = "";
var input = @"The uniqueifier is NULL for the first instance of each customer_id, and is then populated, in ascending order, for each subsequent row with the same customer_id value. The overhead for rows with a NULL uniqueifier value is, unsurprisingly, zero bytes. This is why min_record_size_in_bytes remained unchanged in the overhead table; the first insert had a uniqueifier value of NULL. This is also why it is impossible to estimate how much additional storage overhead will result from the addition of a uniqueifier, without first having a thorough understanding of the data being stored. For example, a non-unique clustered index on a datetime column may have very little overhead if data is inserted, say, once per minute. However, if that same table is receiving thousands of inserts per minute, then it is likely that many rows will share the same datetime value, and so the uniqueifier will have a much higher overhead.
If your requirements seem to dictate the use of a non-unique clustered key, my advice would be to look to see if there are a couple of relatively narrow columns that, together, can form a unique key. You'll still see the increase in the row size for your clustering key in the index pages of both your clustered and nonclustered indexes, but you'll at least save the cost of the uniqueifier in the data pages of the leaf level of your clustered index. Also, instead of storing an arbitrary uniqueifier value to the index key, which is meaningless in the context of your data, you would be adding meaningful and potentially useful information to all of your nonclustered indexes.
A good clustered index is also built upon static, or unchanging, columns. That is, you want to choose a clustering key that will never be updated. SQL Server must ensure that data exists in a logical order based upon the clustering key. Therefore, when the clustering key value is updated, the data may need to be moved elsewhere in the clustered index so that the clustering order is maintained. Consider a table with a clustered index on LastName, and two non-clustered indexes, where the last name of an employee must be updated.";
helper.Append(input);
using (var stream = helper.OpenReadonlyStream())
{
using (var reader = new StreamReader(stream))
{
output = reader.ReadToEnd();
}
}
Assert.AreEqual(input, output);
}
开发者ID:valeriob,项目名称:StreamRepository,代码行数:32,代码来源:PageBlobStateTest.cs
示例9: BlobManager
public BlobManager(string conStr)
{
//RoleEnvironment.GetConfigurationSettingValue("UploadCon")
Storage = CloudStorageAccount.Parse(conStr);
BlobClient = Storage.CreateCloudBlobClient();
QueueClient = Storage.CreateCloudQueueClient();
}
开发者ID:peacecwz,项目名称:AAYazOkuluCloudService,代码行数:7,代码来源:BlobManager.cs
示例10: Run
public static void Run(string connectionString, bool disableLogging)
{
_connectionString = connectionString;
_storageAccount = CloudStorageAccount.Parse(connectionString);
_blobClient = _storageAccount.CreateCloudBlobClient();
Console.WriteLine("Creating the test blob...");
CreateTestBlob();
try
{
TimeSpan azureSDKTime = RunAzureSDKTest();
TimeSpan webJobsSDKTime = RunWebJobsSDKTest(disableLogging);
// Convert to ulong because the measurment block does not support other data type
ulong perfRatio = (ulong)((webJobsSDKTime.TotalMilliseconds / azureSDKTime.TotalMilliseconds) * 100);
Console.WriteLine("--- Results ---");
Console.WriteLine("Azure SDK: {0} ms: ", azureSDKTime.TotalMilliseconds);
Console.WriteLine("WebJobs SDK: {0} ms: ", webJobsSDKTime.TotalMilliseconds);
Console.WriteLine("Perf ratio (x100, long): {0}", perfRatio);
MeasurementBlock.Mark(
perfRatio,
(disableLogging ? BlobNoLoggingOverheadMetric : BlobLoggingOverheadMetric) + ";Ratio;Percent");
}
finally
{
Cleanup();
}
}
开发者ID:chungvinhkhang,项目名称:azure-webjobs-sdk,代码行数:32,代码来源:BlobOverheadPerfTest.cs
示例11: Cleanup
public void Cleanup()
{
StorageCredentials storageCredentials = new StorageCredentials(storageAccountName, storageAccessKey);
CloudStorageAccount account = new CloudStorageAccount(storageCredentials, true);
CloudBlobClient blobClient = account.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
Console.WriteLine("Deleting blob storage files in {0}/{1} older than {2} days", storageAccountName, containerName, minDaysOld);
DateTime referenceDate = DateTime.UtcNow;
var blobQuery = from b in container.ListBlobs(null, recursive).OfType<ICloudBlob>()
where b.Properties.LastModified <= referenceDate.AddDays(-minDaysOld)
select b;
var blobList = blobQuery.ToList();
if (blobList.Count == 0)
{
Console.WriteLine("No files found in {0}/{1} older than {2} days", storageAccountName, containerName, minDaysOld);
return;
}
foreach (ICloudBlob blob in blobList)
{
double blobAgeInDays = (referenceDate - blob.Properties.LastModified.Value).TotalDays;
Console.WriteLine("Deleting blob storage file {0}/{1}, {2} days old", containerName, blob.Name, Math.Round(blobAgeInDays, 3));
blob.DeleteIfExists();
}
Console.WriteLine("{0} blob storage files deleted in {1}/{2} older than {3} days", blobList.Count, storageAccountName, containerName, minDaysOld);
}
开发者ID:GFoley83,项目名称:AzureStorageCleanup,代码行数:33,代码来源:StorageCleaner.cs
示例12: AuditAzureTableProvider
public AuditAzureTableProvider()
{
try
{
_account = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureStorageConnectionString"]);
_client = _account.CreateCloudTableClient();
}
catch (Exception exp)
{
throw new Exception("Error retreiving reference to Azure Storage Account", exp);
}
try
{
_client = _account.CreateCloudTableClient();
}
catch (Exception exp)
{
throw new Exception("Error creating Azure Table Client Object", exp);
}
try
{
_vmAuditTable = _client.GetTableReference("VMAudits");
}
catch (Exception exp)
{
throw new Exception("Error retreiving reference to Azure Table Object", exp);
}
}
开发者ID:smichelotti,项目名称:azureinfrastructure,代码行数:28,代码来源:AuditAzureTableProvider.cs
示例13: AzureTableStorageStatusTraceListener
public AzureTableStorageStatusTraceListener(String initializeData) : base(initializeData)
{
string connectionString = null;
string tableName = "status";
if (initializeData != null)
{
foreach (String keyValuePair in initializeData.Split(','))
{
String[] parts = keyValuePair.Split('*');
if (parts.Length == 2)
{
if (parts[0].Equals("tablestorage", StringComparison.InvariantCultureIgnoreCase))
{
connectionString = parts[1].Trim();
}
else if (parts[0].Equals("table", StringComparison.InvariantCultureIgnoreCase))
{
tableName = parts[1].Trim();
}
}
}
}
if (String.IsNullOrWhiteSpace(connectionString))
{
throw new ArgumentNullException("tablestorage", "The initializeData string must specify the Azure table storage connection string in the tablestorage field.");
}
this._storageAccount = CloudStorageAccount.Parse(connectionString);
this._tableClient = this._storageAccount.CreateCloudTableClient();
this._table = this._tableClient.GetTableReference(tableName);
this._table.CreateIfNotExists();
}
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:34,代码来源:AzureTableStorageStatusTraceListener.cs
示例14: ConstructContainerSas
/// <summary>
/// Constructs a container shared access signature.
/// </summary>
/// <param name="storageAccountName">The Azure Storage account name.</param>
/// <param name="storageAccountKey">The Azure Storage account key.</param>
/// <param name="storageEndpoint">The Azure Storage endpoint.</param>
/// <param name="containerName">The container name to construct a SAS for.</param>
/// <returns>The container URL with the SAS.</returns>
public static string ConstructContainerSas(
string storageAccountName,
string storageAccountKey,
string storageEndpoint,
string containerName)
{
//Lowercase the container name because containers must always be all lower case
containerName = containerName.ToLower();
StorageCredentials credentials = new StorageCredentials(storageAccountName, storageAccountKey);
CloudStorageAccount storageAccount = new CloudStorageAccount(credentials, storageEndpoint, true);
CloudBlobClient client = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = client.GetContainerReference(containerName);
DateTimeOffset sasStartTime = DateTime.UtcNow;
TimeSpan sasDuration = TimeSpan.FromHours(2);
DateTimeOffset sasEndTime = sasStartTime.Add(sasDuration);
SharedAccessBlobPolicy sasPolicy = new SharedAccessBlobPolicy()
{
Permissions = SharedAccessBlobPermissions.Read,
SharedAccessExpiryTime = sasEndTime
};
string sasString = container.GetSharedAccessSignature(sasPolicy);
return string.Format("{0}{1}", container.Uri, sasString); ;
}
开发者ID:romitgirdhar,项目名称:azure-batch-samples,代码行数:37,代码来源:Helpers.cs
示例15: downloadSong
public bool downloadSong(int song_id, string song_name, string song_path)
{
bool flag = false;
//hace la cuenta
StorageCredentials creds = new StorageCredentials(accountName, accountKey);
CloudStorageAccount account = new CloudStorageAccount(creds, useHttps: true);
//crea el cliente
CloudBlobClient client = account.CreateCloudBlobClient();
//crae el contenedor
CloudBlobContainer sampleContainer = client.GetContainerReference("music");
CloudBlockBlob blob = sampleContainer.GetBlockBlobReference(song_id.ToString() + ".mp3");
try
{
//FileIOPermission permission = new FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\\Users\\Andres\\Music");
Console.WriteLine("Path: {0}", song_path + "\\" + song_name);
Stream outputFile = new FileStream(song_path + "\\" + song_name, FileMode.Create);
blob.DownloadToStream(outputFile);
flag = true;
}
catch (Exception e)
{
Console.WriteLine(e);
flag = false;
}
return flag;
}
开发者ID:mefistobases2015,项目名称:OdysseyClient,代码行数:33,代码来源:BlobManager.cs
示例16: WindowsAzureStorageService
public WindowsAzureStorageService(ICmsConfiguration config)
{
try
{
var serviceSection = config.Storage;
string accountName = serviceSection.GetValue("AzureAccountName");
string secretKey = serviceSection.GetValue("AzureSecondaryKey");
bool useHttps = bool.Parse(serviceSection.GetValue("AzureUseHttps"));
if (!TimeSpan.TryParse(serviceSection.GetValue("AzureTokenExpiryTime"), out tokenExpiryTime))
{
tokenExpiryTime = TimeSpan.FromMinutes(10);
}
timeout = serviceSection.ProcessTimeout;
accessControlEnabledGlobally = config.Security.AccessControlEnabled;
containerName = serviceSection.GetValue("AzureContainerName");
securedContainerName = serviceSection.GetValue("AzureSecuredContainerName");
if (string.IsNullOrWhiteSpace(securedContainerName))
{
securedContainerName = containerName;
}
cloudStorageAccount = new CloudStorageAccount(new StorageCredentials(accountName, secretKey), useHttps);
}
catch (Exception e)
{
throw new StorageException(string.Format("Failed to initialize storage service {0}.", GetType()), e);
}
}
开发者ID:vivekmalikymca,项目名称:BetterCMS,代码行数:31,代码来源:WindowsAzureStorageService.cs
示例17: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
Trace.WriteLine("ClassInit");
Test.FullClassName = testContext.FullyQualifiedTestClassName;
StorageAccount = TestBase.GetCloudStorageAccountFromConfig();
//init the blob helper for blob related operations
BlobHelper = new CloudBlobHelper(StorageAccount);
// import module
string moduleFilePath = Test.Data.Get("ModuleFilePath");
if (moduleFilePath.Length > 0)
PowerShellAgent.ImportModule(moduleFilePath);
// $context = New-AzureStorageContext -ConnectionString ...
PowerShellAgent.SetStorageContext(StorageAccount.ToString(true));
BlockFilePath = Path.Combine(Test.Data.Get("TempDir"), FileUtil.GetSpecialFileName());
PageFilePath = Path.Combine(Test.Data.Get("TempDir"), FileUtil.GetSpecialFileName());
FileUtil.CreateDirIfNotExits(Path.GetDirectoryName(BlockFilePath));
FileUtil.CreateDirIfNotExits(Path.GetDirectoryName(PageFilePath));
// Generate block file and page file which are used for uploading
Helper.GenerateMediumFile(BlockFilePath, 1);
Helper.GenerateMediumFile(PageFilePath, 1);
}
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:27,代码来源:CLIBlobFunc.cs
示例18: BlobContainer
public BlobContainer(string name)
{
// hämta connectionsträngen från config // RoleEnviroment bestämmer settingvalue runtime
//var connectionString = RoleEnvironment.GetConfigurationSettingValue("PhotoAppStorage");
//var connectionString = CloudConfigurationManager.GetSetting("CloudStorageApp");
// hämtar kontot utfrån connectionsträngens värde
//var account = CloudStorageAccount.Parse(connectionString);
//var account = CloudStorageAccount.DevelopmentStorageAccount;
var cred = new StorageCredentials("jholm",
"/bVipQ2JxjWwYrZQfHmzhaBx1p1s8BoD/wX6VWOmg4/gpVo/aALrjsDUKqzXsFtc9utepPqe65NposrXt9YsyA==");
var account = new CloudStorageAccount(cred, true);
// skapar en blobclient
_client = account.CreateCloudBlobClient();
m_BlobContainer = _client.GetContainerReference(name);
// Om det inte finns någon container med det namnet
if (!m_BlobContainer.Exists())
{
// Skapa containern
m_BlobContainer.Create();
var permissions = new BlobContainerPermissions()
{
PublicAccess = BlobContainerPublicAccessType.Blob
};
// Sätter public access till blobs
m_BlobContainer.SetPermissions(permissions);
}
}
开发者ID:jonteho,项目名称:cloud-storage,代码行数:32,代码来源:BlobContainer.cs
示例19: AzureFileSystem
public AzureFileSystem(string containerName, string root, bool isPrivate, CloudStorageAccount storageAccount) {
// Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount;
ContainerName = containerName;
_root = String.IsNullOrEmpty(root) ? "": root + "/";
_absoluteRoot = Combine(Combine(_storageAccount.BlobEndpoint.AbsoluteUri, containerName), _root);
//using ( new HttpContextWeaver() )
{
BlobClient = _storageAccount.CreateCloudBlobClient();
// Get and create the container if it does not exist
// The container is named with DNS naming restrictions (i.e. all lower case)
Container = BlobClient.GetContainerReference(ContainerName);
Container.CreateIfNotExists();
Container.SetPermissions(isPrivate
? new BlobContainerPermissions
{PublicAccess = BlobContainerPublicAccessType.Off}
: new BlobContainerPermissions
{PublicAccess = BlobContainerPublicAccessType.Blob}); // deny listing
}
}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:25,代码来源:AzureFileSystem.cs
示例20: Init
public override bool Init(IDictionary<string, string> jobArgsDictionary)
{
try
{
var instrumentationKey = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.InstrumentationKey);
ApplicationInsights.Initialize(instrumentationKey);
var azureCdnPlatform = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnPlatform);
var cloudStorageAccountConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageAccount);
var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);
_cloudStorageAccount = ValidateAzureCloudStorageAccount(cloudStorageAccountConnectionString);
_targetDatabase = new SqlConnectionStringBuilder(databaseConnectionString);
_azureCdnAccountNumber = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnAccountNumber);
_azureCdnPlatform = ValidateAzureCdnPlatform(azureCdnPlatform);
_cloudStorageContainerName = ValidateAzureContainerName(JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.AzureCdnCloudStorageContainerName));
return true;
}
catch (Exception exception)
{
ApplicationInsights.TrackException(exception);
Trace.TraceError(exception.ToString());
}
return false;
}
开发者ID:joyhui,项目名称:NuGet.Jobs,代码行数:26,代码来源:Job.cs
注:本文中的Microsoft.WindowsAzure.Storage.CloudStorageAccount类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论