当前位置: 首页>>代码示例>>C#>>正文


C# CloudTableClient.GetServicePropertiesAsync方法代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Table.CloudTableClient.GetServicePropertiesAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CloudTableClient.GetServicePropertiesAsync方法的具体用法?C# CloudTableClient.GetServicePropertiesAsync怎么用?C# CloudTableClient.GetServicePropertiesAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAzure.Storage.Table.CloudTableClient的用法示例。


在下文中一共展示了CloudTableClient.GetServicePropertiesAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MyClassInitialize

 public static void MyClassInitialize(TestContext testContext)
 {
     client = GenerateCloudTableClient();
     startProperties = client.GetServicePropertiesAsync().AsTask().Result;
 }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:5,代码来源:TableAnalyticsUnitTests.cs

示例2: TestCorsRulesAsync

        private async Task TestCorsRulesAsync(CloudTableClient 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());
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:12,代码来源:TableAnalyticsUnitTests.cs

示例3: TableSasInvalidOperations

        public async Task TableSasInvalidOperations()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();
            CloudTable table = tableClient.GetTableReference("T" + Guid.NewGuid().ToString("N"));

            try
            {
                await table.CreateAsync();
                // Prepare SAS authentication with full permissions
                string sasString = table.GetSharedAccessSignature(
                                        new SharedAccessTablePolicy
                                        {
                                            Permissions = SharedAccessTablePermissions.Delete,
                                            SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30)
                                        },
                                        null,
                                        null,
                                        null,
                                        null,
                                        null);

                CloudTableClient sasClient = new CloudTableClient(tableClient.BaseUri, new StorageCredentials(sasString));

                // Construct a valid set of service properties to upload.
                ServiceProperties properties = new ServiceProperties();
                properties.Logging.Version = "1.0";
                properties.HourMetrics.Version = "1.0";
                properties.Logging.RetentionDays = 9;
                await sasClient.GetServicePropertiesAsync();
                await sasClient.SetServicePropertiesAsync(properties);

                // Test invalid client operations
                // BUGBUG: ListTables hides the exception. We should fix this
                // TestHelpers.ExpectedException(() => sasClient.ListTablesSegmented(), "List tables with SAS", HttpStatusCode.NotFound);
                TestHelper.ExpectedException((ctx) => sasClient.GetServicePropertiesAsync().AsTask().Wait(), "Get service properties with SAS", (int)HttpStatusCode.NotFound);
                TestHelper.ExpectedException((ctx) => sasClient.SetServicePropertiesAsync(properties).AsTask().Wait(), "Set service properties with SAS", (int)HttpStatusCode.NotFound);

                CloudTable sasTable = sasClient.GetTableReference(table.Name);

                // Verify that creation fails with SAS
                TestHelper.ExpectedException((ctx) => sasTable.CreateAsync(null, ctx).AsTask().Wait(), "Create a table with SAS", (int)HttpStatusCode.NotFound);

                // Create the table.
                await table.CreateAsync();

                // Test invalid table operations
                TestHelper.ExpectedException((ctx) => sasTable.DeleteAsync(null, ctx).AsTask().Wait(), "Delete a table with SAS", (int)HttpStatusCode.NotFound);
                TestHelper.ExpectedException((ctx) => sasTable.GetPermissionsAsync(null, ctx).AsTask().Wait(), "Get ACL with SAS", (int)HttpStatusCode.NotFound);
                TestHelper.ExpectedException((ctx) => sasTable.SetPermissionsAsync(new TablePermissions(), null, ctx).AsTask().Wait(), "Set ACL with SAS", (int)HttpStatusCode.NotFound);
            }
            finally
            {
                table.DeleteIfExistsAsync().AsTask().Wait();
            }
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:55,代码来源:TableSasUnitTests.cs

示例4: MyClassInitialize

 public static async Task MyClassInitialize(TestContext testContext)
 {
     client = GenerateCloudTableClient();
     startProperties = await client.GetServicePropertiesAsync();
 }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:5,代码来源:TableAnalyticsUnitTaskTests.cs

示例5: CorsSample

        /// <summary>
        /// Query the Cross-Origin Resource Sharing (CORS) rules for the Table service
        /// </summary>
        /// <param name="tableClient"></param>
        private static async Task CorsSample(CloudTableClient tableClient)
        {
            Console.WriteLine();

            // Get service properties
            Console.WriteLine("Get service properties");
            ServiceProperties originalProperties = await tableClient.GetServicePropertiesAsync();
            try
            {
                // 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 serviceProperties = await tableClient.GetServicePropertiesAsync();
                serviceProperties.Cors.CorsRules.Add(corsRule);
                await tableClient.SetServicePropertiesAsync(serviceProperties);
            }
            finally
            {
                // Revert back to original service properties
                Console.WriteLine("Revert back to original service properties");
                await tableClient.SetServicePropertiesAsync(originalProperties);
            }
            Console.WriteLine();
        }
开发者ID:Azure-Samples,项目名称:storage-table-dotnet-getting-started,代码行数:37,代码来源:AdvancedSamples.cs

示例6: ServicePropertiesSample

        /// <summary>
        /// Manage the properties of the Table service.
        /// </summary>
        /// <param name="tableClient"></param>
        private static async Task ServicePropertiesSample(CloudTableClient tableClient)
        {
            Console.WriteLine();

            // Get service properties
            Console.WriteLine("Get service properties");
            ServiceProperties originalProperties = await tableClient.GetServicePropertiesAsync();
            try
            {
                // Set service properties
                Console.WriteLine("Set service properties");

                ServiceProperties props = await tableClient.GetServicePropertiesAsync();
                props.Logging.LoggingOperations = LoggingOperations.Read | LoggingOperations.Write;
                props.Logging.RetentionDays = 5;
                props.Logging.Version = Constants.AnalyticsConstants.LoggingVersionV1;

                props.HourMetrics.MetricsLevel = MetricsLevel.Service;
                props.HourMetrics.RetentionDays = 6;
                props.HourMetrics.Version = Constants.AnalyticsConstants.MetricsVersionV1;

                props.MinuteMetrics.MetricsLevel = MetricsLevel.Service;
                props.MinuteMetrics.RetentionDays = 6;
                props.MinuteMetrics.Version = Constants.AnalyticsConstants.MetricsVersionV1;

                await tableClient.SetServicePropertiesAsync(props);
            }
            finally
            {
                // Revert back to original service properties
                Console.WriteLine("Revert back to original service properties");
                await tableClient.SetServicePropertiesAsync(originalProperties);
            }
            Console.WriteLine();
        }
开发者ID:Azure-Samples,项目名称:storage-table-dotnet-getting-started,代码行数:39,代码来源:AdvancedSamples.cs


注:本文中的Microsoft.WindowsAzure.Storage.Table.CloudTableClient.GetServicePropertiesAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。