本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.GetServicePropertiesAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobClient.GetServicePropertiesAsync方法的具体用法?C# CloudBlobClient.GetServicePropertiesAsync怎么用?C# CloudBlobClient.GetServicePropertiesAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient
的用法示例。
在下文中一共展示了CloudBlobClient.GetServicePropertiesAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureBlobAnalyticsAsync
/// <summary>
/// Configures logging and metrics for Blob storage, as well as the default service version.
/// Note that if you have already enabled analytics for your storage account, running this sample
/// will change those settings. For that reason, it's best to run with a test storage account if possible.
/// The sample saves your settings and resets them after it has completed running.
/// </summary>
/// <param name="blobClient">The Blob service client.</param>
/// <returns>A Task object.</returns>
private static async Task ConfigureBlobAnalyticsAsync(CloudBlobClient blobClient)
{
try
{
// Get current service property settings.
ServiceProperties serviceProperties = await blobClient.GetServicePropertiesAsync();
// Enable analytics logging and set retention policy to 14 days.
serviceProperties.Logging.LoggingOperations = LoggingOperations.All;
serviceProperties.Logging.RetentionDays = 14;
serviceProperties.Logging.Version = "1.0";
// Configure service properties for hourly and minute metrics.
// Set retention policy to 7 days.
serviceProperties.HourMetrics.MetricsLevel = MetricsLevel.ServiceAndApi;
serviceProperties.HourMetrics.RetentionDays = 7;
serviceProperties.HourMetrics.Version = "1.0";
serviceProperties.MinuteMetrics.MetricsLevel = MetricsLevel.ServiceAndApi;
serviceProperties.MinuteMetrics.RetentionDays = 7;
serviceProperties.MinuteMetrics.Version = "1.0";
// Set the default service version to be used for anonymous requests.
serviceProperties.DefaultServiceVersion = "2015-04-05";
// Set the service properties.
await blobClient.SetServicePropertiesAsync(serviceProperties);
}
catch (StorageException e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
throw;
}
}
示例2: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
client = GenerateCloudBlobClient();
startProperties = client.GetServicePropertiesAsync().AsTask().Result;
}
示例3: TestCorsRulesAsync
private async Task TestCorsRulesAsync(CloudBlobClient client, OperationContext context, IList<CorsRule> corsProps)
{
props.Cors.CorsRules.Clear();
foreach (CorsRule rule in corsProps)
{
props.Cors.CorsRules.Add(rule);
}
await client.SetServicePropertiesAsync(props, null, context);
TestHelper.AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync());
}
示例4: LoadLeftPaneAsync
//******************
//* *
//* LoadLeftPane *
//* *
//******************
// Load a list of storage containers/queues/tables into the left pane of the storage view.
public async Task LoadLeftPaneAsync()
{
Cursor = Cursors.Wait;
NewAction();
AccountTitle.Text = Account.Name;
ClearMainPane();
CloudStorageAccount account = OpenStorageAccount();
blobClient = account.CreateCloudBlobClient();
tableClient = account.CreateCloudTableClient();
queueClient = account.CreateCloudQueueClient();
try
{
var serviceProperties = await blobClient.GetServicePropertiesAsync();
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
{
blobSection.Items.Clear();
queueSection.Items.Clear();
tableSection.Items.Clear();
var tasks = new Task[] { LoadLogsContainerAsync(), LoadBlobContainersAsync(), LoadQueuesAsync(), LoadTablesAsync() };
await Task.WhenAll(tasks);
//switch (itemType)
//{
// case ItemType.BLOB_SERVICE:
// case ItemType.BLOB_CONTAINER:
// blobSection.IsExpanded = true;
// break;
// case ItemType.QUEUE_SERVICE:
// case ItemType.QUEUE_CONTAINER:
// queueSection.IsExpanded = true;
// break;
// case ItemType.TABLE_SERVICE:
// case ItemType.TABLE_CONTAINER:
// tableSection.IsExpanded = true;
// break;
// default:
// blobSection.IsExpanded = true;
// break;
//}
}
catch (Exception ex)
{
ShowError("Error enumerating in storage account: " + ex.Message);
}
Cursor = Cursors.Arrow;
}
示例5: CorsSample
/// <summary>
/// Query the Cross-Origin Resource Sharing (CORS) rules for the Queue service
/// </summary>
/// <param name="blobClient"></param>
private static async Task CorsSample(CloudBlobClient blobClient)
{
// Get CORS rules
Console.WriteLine("Get CORS rules");
ServiceProperties serviceProperties = await blobClient.GetServicePropertiesAsync();
// Add CORS rule
Console.WriteLine("Add CORS rule");
CorsRule corsRule = new CorsRule
{
AllowedHeaders = new List<string> { "*" },
AllowedMethods = CorsHttpMethods.Get,
AllowedOrigins = new List<string> { "*" },
ExposedHeaders = new List<string> { "*" },
MaxAgeInSeconds = 3600
};
serviceProperties.Cors.CorsRules.Add(corsRule);
await blobClient.SetServicePropertiesAsync(serviceProperties);
Console.WriteLine();
}
示例6: MyClassInitialize
public static async Task MyClassInitialize(TestContext testContext)
{
client = GenerateCloudBlobClient();
startProperties = await client.GetServicePropertiesAsync();
}