コード例 #1
0
ファイル: ServiceCORSRule.cs プロジェクト: EmmaZhu/pshtest
        public static void SetSerivceProperties(Constants.ServiceType serviceType, Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties serviceProperties)
        {
            switch (serviceType)
            {
            case Constants.ServiceType.Blob:
                StorageAccount.CreateCloudBlobClient().SetServiceProperties(serviceProperties);
                break;

            case Constants.ServiceType.Queue:
                StorageAccount.CreateCloudQueueClient().SetServiceProperties(serviceProperties);
                break;

            case Constants.ServiceType.Table:
                StorageAccount.CreateCloudTableClient().SetServiceProperties(serviceProperties);
                break;

            case Constants.ServiceType.File:
                FileServiceProperties fileProperties = new FileServiceProperties();
                fileProperties.Cors          = serviceProperties.Cors;
                fileProperties.HourMetrics   = serviceProperties.HourMetrics;
                fileProperties.MinuteMetrics = serviceProperties.MinuteMetrics;
                StorageAccount.CreateCloudFileClient().SetServiceProperties(fileProperties);
                break;
            }
        }
コード例 #2
0
        public async Task Table_IfBoundToICollectorJObject_AddInsertsEntity()
        {
            // Arrange
            const string   expectedValue = "abc";
            StorageAccount account       = CreateFakeStorageAccount();
            CloudQueue     triggerQueue  = await account.CreateQueueAsync(TriggerQueueName);

            await triggerQueue.AddMessageAsync(new CloudQueueMessage(expectedValue));

            // Act
            RunTrigger(account, typeof(BindToICollectorJObjectProgram));

            // Assert
            CloudTableClient client = account.CreateCloudTableClient();
            CloudTable       table  = client.GetTableReference(TableName);

            Assert.True(await table.ExistsAsync());
            DynamicTableEntity entity = table.Retrieve <DynamicTableEntity>(PartitionKey, RowKey);

            Assert.NotNull(entity);
            Assert.NotNull(entity.Properties);

            AssertPropertyValue(entity, "ValueStr", "abcdef");
            AssertPropertyValue(entity, "ValueNum", 123);
        }
コード例 #3
0
 public AzureTableStorage(string tableStorageConnectionString, string tableName)
 {
     TableStorageConnectionString = tableStorageConnectionString;
     StorageAccount   = CloudStorageAccount.Parse(TableStorageConnectionString);
     TableClient      = StorageAccount.CreateCloudTableClient();
     AzureSearchTable = TableClient.GetTableReference(tableName);
 }
コード例 #4
0
ファイル: Table.cs プロジェクト: dut3062796s/Microservice
        /// <summary>
        /// This method initiialises the table storage connector.
        /// </summary>
        public override void Initialize()
        {
            Client = StorageAccount.CreateCloudTableClient();

            if (RequestOptionsDefault != null)
            {
                Client.DefaultRequestOptions = RequestOptionsDefault ??
                                               new TableRequestOptions()
                {
                    RetryPolicy     = new LinearRetry(TimeSpan.FromMilliseconds(200), 5)
                    , ServerTimeout = DefaultTimeout ?? TimeSpan.FromSeconds(1)
                                      //, ParallelOperationThreadCount = 64
                }
            }
            ;

            if (ContainerId == null)
            {
                ContainerId = AzureStorageHelper.GetEnum <DataCollectionSupport>(Support).StringValue;
            }

            ContainerId = StorageServiceBase.ValidateAzureContainerName(ContainerId);

            // Retrieve a reference to the table.
            Table = Client.GetTableReference(ContainerId);

            // Create the table if it doesn't exist.
            Table.CreateIfNotExists();
        }
コード例 #5
0
ファイル: SessionRepository.cs プロジェクト: StephenE/DevoLAN
 public SessionRepository(String storageConnectionString)
 {
     StorageAccount = CloudStorageAccount.Parse(storageConnectionString);
     TableClient    = StorageAccount.CreateCloudTableClient();
     SessionTable   = TableClient.GetTableReference("Sessions");
     SessionTable.CreateIfNotExists();
 }
 public TableStorageRepo()
 {
     StorageAccount = CloudStorageAccount
                      .Parse("DefaultEndpointsProtocol=https;AccountName=anishstoragedemo;AccountKey=KRohowEAfydP3O7KtPlXqlyoUPyPlJI5cp9dQ5cPpmkncnQpPNVDGszUH6p7FptXqn23D6/sRI1mKdtFwgX1qw==;EndpointSuffix=core.windows.net");
     CloudTableClient = StorageAccount?.CreateCloudTableClient();
     TableRef         = this.CloudTableClient.GetTableReference("Todo");
 }
コード例 #7
0
        public DumplingStorageAccount(string connection_string)
        {
            StorageAccount = CloudStorageAccount.Parse(connection_string);

            BlobClient  = StorageAccount.CreateCloudBlobClient();
            TableClient = StorageAccount.CreateCloudTableClient();
            FileClient  = StorageAccount.CreateCloudFileClient();
        }
コード例 #8
0
        public AzureTableRowStorage(IConfiguration configuration)
        {
            string connectionString = configuration.GetValue <string>("AzureWebJobsStorage");

            StorageAccount storageAccount = StorageAccount.NewFromConnectionString(connectionString);

            _tableClient = storageAccount.CreateCloudTableClient();
        }
コード例 #9
0
ファイル: CLITableFunc.cs プロジェクト: EmmaZhu/pshtest
        public void EnumerateAllTables()
        {
            //--------------Get operation--------------
            Test.Assert(CommandAgent.GetAzureStorageTable(""), Utility.GenComparisonData("EnumerateAllTables", true));

            // Verification for returned values
            CommandAgent.OutputValidation(StorageAccount.CreateCloudTableClient().ListTables());
        }
コード例 #10
0
        public CommRepository(StorageAccount storageAccount)
        {
            _blobClient = storageAccount.CreateCloudBlobClient();

            _cloudTableClient = storageAccount.CreateCloudTableClient();

            _cloudQueueClient = storageAccount.CreateCloudQueueClient();
        }
コード例 #11
0
        public static void ClassInit(TestContext context)
        {
            CloudStorageEmulatorShepherd shepherd = new CloudStorageEmulatorShepherd();

            shepherd.Start();

            StorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
            TableClient    = StorageAccount.CreateCloudTableClient();
        }
コード例 #12
0
        /// <summary>
        /// Get a reference to the table. If one doesn't exist create it.
        /// </summary>
        /// <param name="tableAddress">Table address (name).</param>
        /// <returns>Reference to the table.</returns>
        private CloudTable GetTableReference(
            string tableAddress)
        {
            var tableClient = StorageAccount.CreateCloudTableClient();
            var table       = tableClient.GetTableReference(tableAddress);

            table.CreateIfNotExists();

            return(table);
        }
コード例 #13
0
        private void GetCloudTableClient()
        {
            if (String.IsNullOrEmpty(ConnectionString))
            {
                LoadConnectionString();
            }



            _tableClient = StorageAccount.CreateCloudTableClient();
        }
コード例 #14
0
        public StorageRepository(StorageAccount storageAccount, CosmosClient cosmosClient)
        {
            _blobClient = storageAccount.CreateCloudBlobClient();

            _cloudTableClient = storageAccount.CreateCloudTableClient();

            _cloudQueueClient = storageAccount.CreateCloudQueueClient();

            _cosmosClient = cosmosClient;

            var result = CreateStorageIfNotExists().Result;
        }
コード例 #15
0
        async Task <IEnumerable <string> > IEntityRepository.GetEntities()
        {
            var tableClient = StorageAccount.CreateCloudTableClient();
            var table       = tableClient.GetTableReference(TableName);
            var query       = new TableQuery <LuisEntityTableEntity>();
            TableContinuationToken token = null; // if there's more than 1000 rows in the table, this will need to be checked
            var queryResult = await table.ExecuteQuerySegmentedAsync(query, token);

            var result = queryResult.ToList();

            return(result.Select(s => s.Name));
        }
コード例 #16
0
        public static void ClassInit(TestContext context)
        {
            CloudStorageEmulatorShepherd shepherd = new CloudStorageEmulatorShepherd();

            shepherd.Start();

            StorageAccount = CloudStorageAccount.Parse(DevelopmentStorageAccountConnectionString);
            TableClient    = StorageAccount.CreateCloudTableClient();

            CloudTable testTable = SessionRepository.GetTableForSessionData(TableClient, SessionId);

            testTable.DeleteIfExists();
        }
コード例 #17
0
        public static void ClassInit(TestContext context)
        {
            CloudStorageEmulatorShepherd shepherd = new CloudStorageEmulatorShepherd();

            shepherd.Start();

            StorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
            TableClient    = StorageAccount.CreateCloudTableClient();

            CommandTable = CommandQueue.GetCommandQueueTableForSession(TableClient, SessionGuid);
            CommandTable.DeleteIfExists();
            CommandTable.CreateIfNotExists();
        }
コード例 #18
0
        public void OneTimeSetUp()
        {
            Setup.Bootstrap(SetupType.Test);

            CatRepository = IocWrapper.Instance.GetService <ICatRepository>();

            var settings = IocWrapper.Instance.GetService <ISettings>();

            StorageAccount = CloudStorageAccount.Parse(settings.TableStorageConnectionString);

            var tableClient = StorageAccount.CreateCloudTableClient(new TableClientConfiguration());

            CatsTable = tableClient.GetTableReference(settings.CatEntityTableName);
        }
コード例 #19
0
        public static void ClassInit(TestContext context)
        {
            CloudStorageEmulatorShepherd shepherd = new CloudStorageEmulatorShepherd();

            shepherd.Start();

            StorageAccount     = CloudStorageAccount.Parse(DevelopmentStorageAccountConnectionString);
            TableClient        = StorageAccount.CreateCloudTableClient();
            SessionTable       = TableClient.GetTableReference("Sessions");
            SessionPlayerTable = TableClient.GetTableReference("SessionPlayers");

            SessionTable.DeleteIfExists();
            SessionPlayerTable.DeleteIfExists();
        }
コード例 #20
0
ファイル: CLITableFunc.cs プロジェクト: EmmaZhu/pshtest
        public void RemoveNonExistingTable()
        {
            string TABLE_NAME = Utility.GenNameString("nonexisting");

            // Delete the table if it exists
            CloudTable table = StorageAccount.CreateCloudTableClient().GetTableReference(TABLE_NAME);

            table.DeleteIfExists();

            //--------------Remove operation--------------
            Test.Assert(!CommandAgent.RemoveAzureStorageTable(TABLE_NAME), Utility.GenComparisonData("RemoveAzureStorageTable", false));
            // Verification for returned values
            Test.Assert(CommandAgent.Output.Count == 0, "Only 0 row returned : {0}", CommandAgent.Output.Count);
            CommandAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name, TABLE_NAME);
        }
コード例 #21
0
ファイル: CloudStorage.cs プロジェクト: Elringus/SagaNetwork
        public static void Initialize()
        {
            StorageAccount = CloudStorageAccount.Parse(connectionString);

            // Disabling nagle for table improves performance:
            // https://blogs.msdn.microsoft.com/windowsazurestorage/2010/06/25/nagles-algorithm-is-not-friendly-towards-small-requests/
            var tableServicePoint = ServicePointManager.FindServicePoint(StorageAccount.TableEndpoint);

            tableServicePoint.UseNagleAlgorithm = false;

            TableClient = StorageAccount.CreateCloudTableClient();
            BlobClient  = StorageAccount.CreateCloudBlobClient();

            BlobContainer = BlobClient.GetContainerReference($"saga-{Configuration.TierAffix}-container");
            BlobContainer.CreateIfNotExists();
        }
コード例 #22
0
        private async Task Initialzie()
        {
            if (StorageAccount == null)
            {
                // Retrieve storage account from connection string.
                StorageAccount = CloudStorageAccount.Parse(_connectionString);

                // Create the table client
                TableClient = StorageAccount.CreateCloudTableClient();

                // Retrieve reference to a previously created container.
                CloudTable = TableClient.GetTableReference(_imageTableName);

                // Create the container if it doesn't already exist.
                await CloudTable.CreateIfNotExistsAsync();
            }
        }
コード例 #23
0
ファイル: SetServiceLogging.cs プロジェクト: EmmaZhu/pshtest
        public void SetLoggingVersion()
        {
            //Blob service
            CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();

            GenericSetLoggingVersion(ServiceType.Blob, () => blobClient.GetServiceProperties());

            //Queue service
            CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient();

            GenericSetLoggingVersion(ServiceType.Queue, () => queueClient.GetServiceProperties());

            //Table service
            CloudTableClient tableClient = StorageAccount.CreateCloudTableClient();

            GenericSetLoggingVersion(ServiceType.Table, () => tableClient.GetServiceProperties());
        }
コード例 #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigResolverTableStorage"/> class.
        /// </summary>
        /// <param name="storageAccount">The storage account.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="partitionKey">The table partition key for the configuration settings.</param>
        /// <param name="propertyKey">The Azure table storage configuration default property key, currently "Value"</param>
        /// <param name="RequestOptionsDefault">You can set this to enable a more specific retry policy.</param>
        public ConfigResolverTableStorage(CloudStorageAccount storageAccount
                                          , string tableName    = AzureExtensionMethods.AzureTableStorageConfigDefaultTableName
                                          , string partitionKey = AzureExtensionMethods.AzureTableStorageConfigDefaultPartitionKey
                                          , string propertyKey  = AzureExtensionMethods.AzureTableStorageConfigDefaultPropertyKey
                                          , TableRequestOptions RequestOptionsDefault = null
                                          )
        {
            PartitionKey = partitionKey ?? "";

            PropertyKey    = propertyKey ?? throw new ArgumentNullException("propertyKey", $"{nameof(ConfigResolverTableStorage)} propertyKey cannot be null");
            TableName      = tableName ?? throw new ArgumentNullException("tableName", $"{nameof(ConfigResolverTableStorage)} tableName cannot be null");
            StorageAccount = storageAccount ?? throw new ArgumentNullException("storageAccount", $"{nameof(ConfigResolverTableStorage)} storageAccount cannot be null");

            Client = StorageAccount.CreateCloudTableClient();

            Client.DefaultRequestOptions = RequestOptionsDefault ?? DefaultTableRequestOptions();

            Table = Client.GetTableReference(TableName);
        }
コード例 #25
0
        public void OneTimeSetUp()
        {
            Setup.Bootstrap(SetupType.Test);

            CatRepository = IocWrapper.Instance.GetService <ICatRepository>();

            var settings = IocWrapper.Instance.GetService <ISettings>();

            StorageAccount = CloudStorageAccount.Parse(settings.StorageAccountConnection);

            var tableClient = StorageAccount.CreateCloudTableClient(new TableClientConfiguration());

            CatsTable = tableClient.GetTableReference(settings.CatEntityTableName);

            foreach (var cat in TestData.Cats)
            {
                CatsTable.Execute(TableOperation.Insert(cat));
            }
        }
コード例 #26
0
        public static void InitializeConnections()
        {
            string connectionString = SharedConfig.AzureStorageConnectionString;

            AzureStorage.StorageAccount = CloudStorageAccount.Parse(connectionString);

            CloudTableClient tableClient = StorageAccount.CreateCloudTableClient();

            AccountTable = tableClient.GetTableReference("account");
            AccountTable.CreateIfNotExists();

            ActivityTable = tableClient.GetTableReference("activity");
            ActivityTable.CreateIfNotExists();

            CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient();

            SubscriptionQueue = queueClient.GetQueueReference("subscriptions");
            SubscriptionQueue.CreateIfNotExists();
        }
コード例 #27
0
        public async Task Table_IfBoundToCloudTable_BindsAndCreatesTable()
        {
            // Arrange
            StorageAccount account      = CreateFakeStorageAccount();
            CloudQueue     triggerQueue = await account.CreateQueueAsync(TriggerQueueName);

            await triggerQueue.AddMessageAsync(new CloudQueueMessage("ignore"));

            // Act
            CloudTable result = RunTrigger <CloudTable>(account, typeof(BindToCloudTableProgram),
                                                        (s) => BindToCloudTableProgram.TaskSource = s);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(TableName, result.Name);
            CloudTableClient client = account.CreateCloudTableClient();
            CloudTable       table  = client.GetTableReference(TableName);

            Assert.True(await table.ExistsAsync());
        }
コード例 #28
0
ファイル: SetServiceMetrics.cs プロジェクト: EmmaZhu/pshtest
        public void SetMetricsVersion()
        {
            //Blob service
            CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();

            GenericSetMetricsVersion(ServiceType.Blob, () => blobClient.GetServiceProperties());

            //Queue service
            CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient();

            GenericSetMetricsVersion(ServiceType.Queue, () => queueClient.GetServiceProperties());

            //Table service
            CloudTableClient tableClient = StorageAccount.CreateCloudTableClient();

            GenericSetMetricsVersion(ServiceType.Table, () => tableClient.GetServiceProperties());

            //File service
            GenericSetMetricsVersion(ServiceType.File, () => Utility.GetServiceProperties(StorageAccount, ServiceType.File));
        }
コード例 #29
0
ファイル: Table.cs プロジェクト: wangzhefeng2000/Microservice
        public override void Initialize()
        {
            Client = StorageAccount.CreateCloudTableClient();

            if (RequestOptionsDefault != null)
            {
                Client.DefaultRequestOptions = RequestOptionsDefault;
            }

            if (ContainerId == null)
            {
                ContainerId = AzureStorageHelper.GetEnum <DataCollectionSupport>(Support).StringValue;
            }

            ContainerId = StorageServiceBase.ValidateAzureContainerName(ContainerId);

            // Retrieve a reference to the table.
            Table = Client.GetTableReference(ContainerId);

            // Create the table if it doesn't exist.
            Table.CreateIfNotExists();
        }
コード例 #30
0
        private async static Task Clean(StorageAccount account)
        {
            CloudBlobClient blobClient = account.CreateCloudBlobClient();

            foreach (var testContainer in (await blobClient.ListContainersSegmentedAsync(TestArtifactPrefix, null)).Results)
            {
                await testContainer.DeleteAsync();
            }

            CloudTableClient tableClient = account.CreateCloudTableClient();

            foreach (var table in await tableClient.ListTablesSegmentedAsync(TestArtifactPrefix, null))
            {
                await table.DeleteAsync();
            }

            CloudQueueClient queueClient = account.CreateCloudQueueClient();

            foreach (var queue in (await queueClient.ListQueuesSegmentedAsync(TestArtifactPrefix, null)).Results)
            {
                await queue.DeleteAsync();
            }
        }