本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.GetServiceProperties方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobClient.GetServiceProperties方法的具体用法?C# CloudBlobClient.GetServiceProperties怎么用?C# CloudBlobClient.GetServiceProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient
的用法示例。
在下文中一共展示了CloudBlobClient.GetServiceProperties方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadBlobInChunks
static void UploadBlobInChunks(FileInfo fileInfo, CloudBlockBlob packageBlob, CloudBlobClient blobClient)
{
var operationContext = new OperationContext();
operationContext.ResponseReceived += delegate(object sender, RequestEventArgs args)
{
var statusCode = (int) args.Response.StatusCode;
var statusDescription = args.Response.StatusDescription;
Log.Verbose("Uploading, response received: " + statusCode + " " + statusDescription);
if (statusCode >= 400)
{
Log.Error("Error when uploading the package. Azure returned a HTTP status code of: " +
statusCode + " " + statusDescription);
Log.Verbose("The upload will be retried");
}
};
blobClient.SetServiceProperties(blobClient.GetServiceProperties(), operationContext: operationContext);
Log.VerboseFormat("Uploading the package to blob storage. The package file is {0}.", fileInfo.Length.ToFileSizeString());
using (var fileReader = fileInfo.OpenRead())
{
var blocklist = new List<string>();
long uploadedSoFar = 0;
var data = new byte[1024 * 1024];
var id = 1;
while (true)
{
id++;
var read = fileReader.Read(data, 0, data.Length);
if (read == 0)
{
packageBlob.PutBlockList(blocklist);
break;
}
var blockId = Convert.ToBase64String(Encoding.UTF8.GetBytes(id.ToString(CultureInfo.InvariantCulture).PadLeft(30, '0')));
packageBlob.PutBlock(blockId, new MemoryStream(data, 0, read, true), null);
blocklist.Add(blockId);
uploadedSoFar += read;
Log.VerboseFormat("Uploading package to blob storage: {0} of {1}", uploadedSoFar.ToFileSizeString(), fileInfo.Length.ToFileSizeString());
}
}
Log.Verbose("Upload complete");
}
示例2: UpdateServiceProperties
private static void UpdateServiceProperties(CloudBlobClient blobClient, List<string> origins, List<string> headers, List<string> methods)
{
ServiceProperties props = blobClient.GetServiceProperties();
Trace.Write(props.Cors.CorsRules.ToString());
if (! ContainsOrigin(props.Cors.CorsRules, origins))
{
props.Cors.CorsRules.Add(
new CorsRule
{
AllowedOrigins = origins,
AllowedHeaders = headers,
AllowedMethods = ExpandCorsHttpMethods(methods),
MaxAgeInSeconds = 1800 // 30 minutes
});
blobClient.SetServiceProperties(props);
}
}
示例3: CurrentProperties
private static ServiceProperties CurrentProperties(CloudBlobClient blobClient)
{
var currentProperties = blobClient.GetServiceProperties();
if (currentProperties != null)
{
if (currentProperties.Cors != null)
{
Console.WriteLine("Cors.CorsRules.Count : " + currentProperties.Cors.CorsRules.Count);
for (int index = 0; index < currentProperties.Cors.CorsRules.Count; index++)
{
var corsRule = currentProperties.Cors.CorsRules[index];
Console.WriteLine("corsRule[index] : " + index);
foreach (var allowedHeader in corsRule.AllowedHeaders)
{
Console.WriteLine("corsRule.AllowedHeaders : " + allowedHeader);
}
Console.WriteLine("corsRule.AllowedMethods : " + corsRule.AllowedMethods);
foreach (var allowedOrigins in corsRule.AllowedOrigins)
{
Console.WriteLine("corsRule.AllowedOrigins : " + allowedOrigins);
}
foreach (var exposedHeaders in corsRule.ExposedHeaders)
{
Console.WriteLine("corsRule.ExposedHeaders : " + exposedHeaders);
}
Console.WriteLine("corsRule.MaxAgeInSeconds : " + corsRule.MaxAgeInSeconds);
}
}
Console.WriteLine("DefaultServiceVersion : " + currentProperties.DefaultServiceVersion);
Console.WriteLine("HourMetrics.MetricsLevel : " + currentProperties.HourMetrics.MetricsLevel);
Console.WriteLine("HourMetrics.RetentionDays : " + currentProperties.HourMetrics.RetentionDays);
Console.WriteLine("HourMetrics.Version : " + currentProperties.HourMetrics.Version);
Console.WriteLine("Logging.LoggingOperations : " + currentProperties.Logging.LoggingOperations);
Console.WriteLine("Logging.RetentionDays : " + currentProperties.Logging.RetentionDays);
Console.WriteLine("Logging.Version : " + currentProperties.Logging.Version);
Console.WriteLine("MinuteMetrics.MetricsLevel : " + currentProperties.MinuteMetrics.MetricsLevel);
Console.WriteLine("MinuteMetrics.RetentionDays : " + currentProperties.MinuteMetrics.RetentionDays);
Console.WriteLine("MinuteMetrics.Version : " + currentProperties.MinuteMetrics.Version);
}
return currentProperties;
}
示例4: azureDriver
public azureDriver(string connStr, string containerName) {
//var connStr = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", accountName, accountKey);
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connStr);
blobClient = storageAccount.CreateCloudBlobClient();
var props = blobClient.GetServiceProperties();
if (props.Cors.CorsRules.Count == 0) {
props.Cors.CorsRules.Add(new CorsRule() {
AllowedHeaders = new List<string>() { "*" },
AllowedMethods = CorsHttpMethods.Get,
AllowedOrigins = new List<string>() { "*" },
ExposedHeaders = new List<string>() { "*" },
MaxAgeInSeconds = 18000 // 300 minutes
});
blobClient.SetServiceProperties(props);
}
container = blobClient.GetContainerReference(containerName);
if (container.CreateIfNotExists()) container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });
}
示例5: LoadLeftPane
//******************
//* *
//* LoadLeftPane *
//* *
//******************
// Load a list of storage containers/queues/tables into the left pane of the storage view.
public void LoadLeftPane()
{
Cursor = Cursors.Wait;
NewAction();
AccountTitle.Text = Account.Name;
ClearMainPane();
TreeViewItem blobSection = new TreeViewItem()
{
Header = "Blob Containers",
Tag = new OutlineItem()
{
ItemType = ItemType.BLOB_SERVICE /* 100 */,
Container = null
}
};
TreeViewItem queueSection = new TreeViewItem()
{
Header = "Queues",
Tag = new OutlineItem()
{
ItemType = ItemType.QUEUE_SERVICE /* 200 */,
Container = null
}
};
TreeViewItem tableSection = new TreeViewItem()
{
Header = "Tables",
Tag = new OutlineItem()
{
ItemType = ItemType.TABLE_SERVICE /* 300 */,
Container = null
}
};
AccountTreeView.Items.Clear();
AccountTreeView.Items.Add(blobSection);
AccountTreeView.Items.Add(queueSection);
AccountTreeView.Items.Add(tableSection);
CloudStorageAccount account = OpenStorageAccount();
blobClient = account.CreateCloudBlobClient();
tableClient = account.CreateCloudTableClient();
queueClient = account.CreateCloudQueueClient();
try
{
var serviceProperties = blobClient.GetServiceProperties();
if (serviceProperties.Cors.CorsRules.Count == 0)
{
ButtonBlobServiceCORSIcon.Source = new BitmapImage(new Uri("pack://application:,,/Images/unchecked.png"));
ButtonBlobServiceCORSLabel.Text = "CORS";
}
else
{
ButtonBlobServiceCORSIcon.Source = new BitmapImage(new Uri("pack://application:,,/Images/checked.png"));
ButtonBlobServiceCORSLabel.Text = "CORS (" + serviceProperties.Cors.CorsRules.Count.ToString() + ")";
}
}
catch(Exception)
{
// Disallowed for developer storage account.
}
try
{
// Check for $logs container and add it if present ($logs is not included in the general ListContainers call).
CloudBlobContainer logsContainer = blobClient.GetContainerReference("$logs");
if (logsContainer.Exists())
{
StackPanel stack = new StackPanel();
stack.Orientation = Orientation.Horizontal;
Image cloudFolderImage = new Image();
cloudFolderImage.Source = new BitmapImage(new Uri("pack://application:,,/Images/cloud_folder.png"));
cloudFolderImage.Height = 24;
Label label = new Label();
label.Content = logsContainer.Name;
stack.Children.Add(cloudFolderImage);
stack.Children.Add(label);
TreeViewItem blobItem = new TreeViewItem()
//.........这里部分代码省略.........
示例6: SetCors
private void SetCors(CloudBlobClient blobClient)
{
var newProperties = blobClient.GetServiceProperties();
try
{
ConfigureCors(newProperties);
var blobprop = blobClient.GetServiceProperties();
// "2011-08-18"; // null;
blobClient.SetServiceProperties(newProperties);
}
catch (Exception ex)
{
//throw;
}
}
示例7: TestCorsRules
private void TestCorsRules(CloudBlobClient client, IList<CorsRule> corsProps)
{
props.Cors.CorsRules.Clear();
foreach (CorsRule rule in corsProps)
{
props.Cors.CorsRules.Add(rule);
}
client.SetServiceProperties(props);
TestHelper.AssertServicePropertiesAreEqual(props, client.GetServiceProperties());
}
示例8: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
client = GenerateCloudBlobClient();
startProperties = client.GetServiceProperties();
}