private void Connect()
        {
            connected = false;

            int trycount = 0;

            while (trycount++ < 3)
            {
                try
                {
                    string connectionString = RoleEnvironment.GetConfigurationSettingValue(connectionStringName);
                    _storageAccount          = CloudStorageAccount.Parse(connectionString);
                    _tableClient             = new CloudTableClient(_storageAccount.TableEndpoint.AbsoluteUri, _storageAccount.Credentials);
                    _tableClient.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1));
                    if (!_tableClient.DoesTableExist(tableName))
                    {
                        _tableClient.CreateTableIfNotExist(tableName);
                    }

                    connected = true;
                    break;
                }
                catch
                {
                }
            }

            if (!connected)
            {
                throw new Exception("Could not connect to table service");
            }
        }
예제 #2
0
        private void Connect()
        {
            connected = false;

            int trycount = 0;

            while (trycount++ < 3)
            {
                try
                {
                    //comment added just for test
                    string connectionString = "DefaultEndpointsProtocol=https; AccountName=careerthesaurus; AccountKey=52D4zWvYaIL6gfl4FUt6y8cc9Ar8UV8EWNmBttpraVkMJjcy+cOlDhiZYTnmGZLdpKV1nwlNNlGQJiqZh9rlxQ==";
                    _storageAccount          = CloudStorageAccount.Parse(connectionString);
                    _tableClient             = new CloudTableClient(_storageAccount.TableEndpoint.AbsoluteUri, _storageAccount.Credentials);
                    _tableClient.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1));
                    if (!_tableClient.DoesTableExist(tableName))
                    {
                        _tableClient.CreateTableIfNotExist(tableName);
                    }

                    connected = true;
                    break;
                }
                catch
                {
                }
            }

            if (!connected)
            {
                throw new Exception("Could not connect to table service");
            }
        }
예제 #3
0
        private static bool CreateTable(string tableName)
        {
            CloudTableClient tc = account.CreateCloudTableClient();

            DateTime retryUntil = DateTime.Now + s_retryTimeout;

            while (!tc.DoesTableExist(tableName))
            {
                try
                {
                    tc.CreateTable(tableName);
                    WriteInFile(filename, tableName + " was created");
                    return(true);
                }
                catch (StorageClientException e)
                {
                    if (e.ErrorCode == StorageErrorCode.ResourceAlreadyExists &&
                        e.StatusCode == HttpStatusCode.Conflict &&
                        DateTime.Now < retryUntil)
                    {
                        Console.WriteLine("Retrying {0}...", tableName);
                        Thread.Sleep(s_retryWaitTime);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            WriteInFile(filename, tableName + " already created");
            return(false);
        }
예제 #4
0
        public void AzureTableCreateDataStoreDelete()
        {
            var table = new AzureTable <EntityWithDataStore>(CloudStorageAccount.DevelopmentStorageAccount);

            table.EnsureExist();

            var cloudTableClient = new CloudTableClient(CloudStorageAccount.DevelopmentStorageAccount.TableEndpoint.ToString(), CloudStorageAccount.DevelopmentStorageAccount.Credentials);
            var success          = cloudTableClient.DoesTableExist("testtablename");

            Assert.IsTrue(success);

            table.DeleteIfExist();

            success = cloudTableClient.DoesTableExist("testtablename");
            Assert.IsFalse(success);
        }
예제 #5
0
 public void WriteStatusEntry(Guid requestId, String message)
 {
     _tableClient.CreateTableIfNotExist("status");
     if (_tableClient.DoesTableExist("status"))
     {
         Context.AddObject("status", new StatusEntry(requestId, RoleEnvironment.CurrentRoleInstance.Id, message));
         Context.SaveChanges();
     }
 }
        /// <summary>
        /// Cehck is table<see cref="WADPerformanceTable"/>exists in storage service
        /// </summary>
        /// <param name="accountName"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static Boolean IsPerfomanceTableExists(String accountName, String key)
        {
            CloudTableClient cloudTableClient = GetClient(accountName, key);

            return(cloudTableClient.DoesTableExist(WADPerformanceTable.TableName));
        }
예제 #7
0
 public bool DoesTableExist(string tableName)
 {
     return(client.DoesTableExist(tableName));
 }
예제 #8
0
        private static bool DoesTableExists(string tableName)
        {
            CloudTableClient tc = s_account.CreateCloudTableClient();

            return(tc.DoesTableExist(tableName));
        }