Example #1
0
 protected CloudCoreStoredTable(string accountSonnectionString = "")
 {
     SetAccount(accountSonnectionString);
     cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
     cloudTable = cloudTableClient.GetTableReference(GetType().Name.Replace("Entity", "").Replace("Table", "").ToLower());
     cloudTable.CreateIfNotExists();
 }
        public TProduct(string affiliate, string code, int qty, bool force_lookup = false)
        {
            ProductCode = code;
            Qty = qty;

            cloud = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("AbundaStorage"));

            client = cloud.CreateCloudTableClient();

            products = client.GetTableReference("Products");
            products.CreateIfNotExists();

            using (var context = new DataBaseDataContext())
            {
                var aff = (from ev in context.Affiliates
                           where ev.code == affiliate
                           select ev).FirstOrDefault();

                merchantID = aff.MerchantID;
                marketplaceID = aff.MarketPlaceID;
                secretKey = aff.SecretKey;
                accessKey = aff.AccessKey;
            }

            var amzResults = PerformAmazonLookup();
        }
Example #3
0
        public static void Main()
        {
     //       string connectionString =
     //ConfigurationManager.ConnectionStrings["RootManageSharedAccessKey"].ConnectionString;
     //       Action<BrokeredMessage> callback = x =>
     //       {
                
     //       };
     //       var clients = new List<SubscriptionClient>();
     //       for (int i = 0; i < 5; i++)
     //       {
     //           var client = TopicClient.CreateFromConnectionString(connectionString, "signalr_topic_push_" + i);
     //           client.
     //           client.OnMessage(callback);
     //           clients.Add(client);
     //       }
     //       Console.ReadLine();
            //var ctx = GlobalHost.ConnectionManager.GetHubContext<yourhub>();
            //ctx.Clients.Client(connectionId).< your method >

            var cloudStorage = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["DataStorage"].ConnectionString);
            var tableClient = cloudStorage.CreateCloudTableClient();
            _tickEvents = tableClient.GetTableReference("tickevents");
            _tickEvents.CreateIfNotExists();
            var host = new JobHost();
            var cancelToken = new WebJobsShutdownWatcher().Token;
            _eventHubClient = EventHubClient.CreateFromConnectionString(ConfigurationManager.ConnectionStrings["IotHubConnection"].ConnectionString, iotHubD2cEndpoint);
            var d2CPartitions = _eventHubClient.GetRuntimeInformation().PartitionIds;
            Task.WaitAll(d2CPartitions.Select(partition => ListenForEvent(host, partition, cancelToken)).ToArray(), cancelToken);
            host.RunAndBlock();
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="storageConnectionString">Storage account connection string</param>
        /// <param name="azureTablePrefix">The repository stores data in two tables called httprequestbycorrelationid and httprequestbydatedescending, if this parameter is not null and not whitespace then it is used as a prefix for those table names.</param>
        /// <param name="granularity">The level of granularity for data in the partition. On a low traffic site hourly or even daily can be useful, whereas busy sites minute or second are more useful.</param>
        public AzureHttpLoggerRepository(string storageConnectionString, string azureTablePrefix, LogByDateGranularityEnum granularity)
        {
            if (string.IsNullOrWhiteSpace(storageConnectionString)) throw new ArgumentNullException(nameof(storageConnectionString));
            if (azureTablePrefix == null)
            {
                azureTablePrefix = "";
            }
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
            CloudTableClient client = storageAccount.CreateCloudTableClient();
            _byCorrelationIdTable = client.GetTableReference(string.Concat(azureTablePrefix, RequestByCorrelationIdTableName));
            _byDateTimeDescendingTable = client.GetTableReference(string.Concat(azureTablePrefix, RequestByDateTimeDescendingTableName));

            _byCorrelationIdTable.CreateIfNotExists();
            _byDateTimeDescendingTable.CreateIfNotExists();

            switch (granularity)
            {
                case LogByDateGranularityEnum.Hour:
                    _granularPartitionKeyFormat = "yyyy-MM-dd hh";
                    break;

                case LogByDateGranularityEnum.Day:
                    _granularPartitionKeyFormat = "yyyy-MM-dd";
                    break;

                case LogByDateGranularityEnum.Minute:
                    _granularPartitionKeyFormat = "yyyy-MM-dd hh:mm";
                    break;

                case LogByDateGranularityEnum.Second:
                    _granularPartitionKeyFormat = "yyyy-MM-dd hh:mm:ss";
                    break;
            }
        }
 public AzureTableStorageProjectionMetaDataRepository Initialize(string connectionString)
 {
     var client = GetTableClient(connectionString);
     _table = client.GetTableReference("ProjectionMetaData");
     _table.CreateIfNotExists();
     return this;
 }
 public AzureTableStorageEventSource Initialize(string connectionString)
 {
     var client = GetTableClient(connectionString);
     _table = client.GetTableReference("EventSource");
     _table.CreateIfNotExists();
     return this;
 }
Example #7
0
        public override bool OnStart()
        {
            ServicePointManager.DefaultConnectionLimit = Environment.ProcessorCount;

            ConfigureDiagnostics();

            // Read storage account configuration settings
            Trace.TraceInformation("Initializing storage account in WorkerC");
            var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(
                "StorageConnectionString"
                ));

            // Initialize queue storage
            Trace.TraceInformation("Creating queue client in WorkerC");
            var queueClient = storageAccount.CreateCloudQueueClient();
            subscribeQueue = queueClient.GetQueueReference("subscribequeue");

            // Initialize table storage
            Trace.TraceInformation("Creating table client in WorkerC");
            var tableClient = storageAccount.CreateCloudTableClient();
            subscribersTable = tableClient.GetTableReference("Subscribers");

            Trace.TraceInformation("WorkerC: Creating blob container, queue, tables, if they don't exist.");
            subscribeQueue.CreateIfNotExists();
            subscribersTable.CreateIfNotExists();

            return base.OnStart();
        }
 public RegistrationKeyStorage(string connectionString)
 {
     var account = CloudStorageAccount.Parse(connectionString);
     var tableClient = account.CreateCloudTableClient();
     _registrationKeysTable = tableClient.GetTableReference("RegistrationKeys");
     _registrationKeysTable.CreateIfNotExists();
 }
Example #9
0
 protected RepositoryBase(string table)
 {
     var storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
     var tableClient = storageAccount.CreateCloudTableClient();
     _table = tableClient.GetTableReference(table);
     _table.CreateIfNotExists();
 }
Example #10
0
 public BatchInsertTests()
 {
     var account = Util.GetStorageAccount();
     var client = account.CreateCloudTableClient();
     _table = client.GetTableReference("BatchOperationTests");
     _table.CreateIfNotExists();
 }
Example #11
0
        public HomeController()
        {
            storageAccount = CloudStorageAccount.Parse(
            ConfigurationManager.AppSettings["StorageConnectionString"]);

            tableClient = storageAccount.CreateCloudTableClient();

            table = tableClient.GetTableReference("fouramigos");

            table.CreateIfNotExists();

            blobClient = storageAccount.CreateCloudBlobClient();

            container = blobClient.GetContainerReference("fouramigos");

            container.CreateIfNotExists();

            BlobContainerPermissions permissions = container.GetPermissions();
            permissions.PublicAccess = BlobContainerPublicAccessType.Container;
            container.SetPermissions(permissions);


            //lägga till nya
            //var tablemodels = new TableModel("Brutus", "Uggla") { Location = "T4", Description="Uggla i träd", Type="Foto" };
            //var tablemodels1 = new TableModel("brutus", "Örn") { Location = "T4", Description="Örn som flyger", Type = "Foto" };

            //var opreation = TableOperation.Insert(tablemodels);
            //var operation2 = TableOperation.Insert(tablemodels1);

            //table.Execute(opreation);
            //table.Execute(operation2);
        }
 static VerificationLogger()
 {
     CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
     CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
     table = tableClient.GetTableReference("MultiHostedEndpointsOutput");
     table.CreateIfNotExists();
 }
Example #13
0
 public LogSaver(string connectionString)
 {
     var account = CloudStorageAccount.Parse(connectionString);
     var client = account.CreateCloudTableClient();
     _table = client.GetTableReference(TableName);
     _table.CreateIfNotExists();
 }
Example #14
0
 public TableDal(string storageConnectionString, string tableName)
 {
     var storageAccount = CloudStorageAccount.Parse(storageConnectionString);
     var tableClient = storageAccount.CreateCloudTableClient();
     _table = tableClient.GetTableReference(tableName);
     _table.CreateIfNotExists();
 }
        public Crawler()
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            table = tableClient.GetTableReference("crawlertable");
            table.CreateIfNotExists();
            datatable = tableClient.GetTableReference("datatable");
            datatable.CreateIfNotExists();

            CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
            urlQueue = queueClient.GetQueueReference("urlqueue");
            urlQueue.CreateIfNotExists();
            adminQueue = queueClient.GetQueueReference("adminqueue");
            adminQueue.CreateIfNotExists();

            alreadyVisitedUrls = new HashSet<String>();
            disallowedUrls = new HashSet<String>();
            errorUrls = new HashSet<String>();

            tableSize = 0;
            totalUrls = 0;
            counter = 1;

            compareDate = DateTime.ParseExact("2015-04-01", "yyyy-MM-dd", CultureInfo.InvariantCulture);

            //Regex to check for valid html document
            rgx = new Regex(@"^[a-zA-Z0-9\-]+.?(htm|html)?$");
        }
Example #16
0
 public PostBackup(CloudStorageAccount storageAccount)
 {
     _iDbService = new DbService();
     CloudTableClient c = storageAccount.CreateCloudTableClient();
     _table = c.GetTableReference("Post");
     _table.CreateIfNotExists();
     _retryPolicy = RetryService.GetRetryPolicy();
 }
        public virtual void Init()
        {
            var client = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudTableClient();
            _table = client.GetTableReference("kalixleotablecontext");
            _table.CreateIfNotExists();

            _azureTable = new AzureTableContext(_table, null);
        }
 public ProcessTrackInfoHelper(string strConn)
 {
     storageAccount = CloudStorageAccount.Parse(strConn);
     CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
     // Create the table if it doesn't exist.
     table = tableClient.GetTableReference("wamsbutlerprocesstrack");
     table.CreateIfNotExists();
 }
Example #19
0
 public PostBackup(CloudStorageAccount storageAccount, string endpointUrl, string authorizationKey)
 {
     _iDbService = new DbService(endpointUrl,authorizationKey);
     CloudTableClient c = storageAccount.CreateCloudTableClient();
     _table = c.GetTableReference("Post");
     _table.CreateIfNotExists();
     _retryPolicy = _iDbService.GetRetryPolicy();
 }
Example #20
0
 public AzureTableStorageBrain(string connectionString, string partitionKey)
 {
     _partitionKey = partitionKey;
     CloudStorageAccount storrageAccount = CloudStorageAccount.Parse(connectionString);
     CloudTableClient tableClient = storrageAccount.CreateCloudTableClient();
     _table = tableClient.GetTableReference(NbotTableName);
     _table.CreateIfNotExists();
 }
Example #21
0
 public AzureStorageService()
 {
     storageConnectionString = ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ToString();
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
     CloudTableClient c = storageAccount.CreateCloudTableClient();
     _cloudTable = c.GetTableReference("Chat");
     _cloudTable.CreateIfNotExists();
 }
 public ProcessStorage()
 {
     var connString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
     var storageAccount = CloudStorageAccount.Parse(connString);
     var client = storageAccount.CreateCloudTableClient();
     processesTable = client.GetTableReference("Processes");
     processesTable.CreateIfNotExists();
 }
Example #23
0
 public ChatBackup(CloudStorageAccount storageAccount)
 {
     var client = storageAccount.CreateCloudTableClient();
     _table = client.GetTableReference("Chat");
     _table.CreateIfNotExists();
     _iDbService = new DbService();
     _retryPolicy = _iDbService.GetRetryPolicy();
 }
 private void EnsureTable(string tableName)
 {
     var account = CloudStorageAccount.Parse(_connectionString);
     var client = account.CreateCloudTableClient();
     _table = client.GetTableReference(tableName);
     _table.CreateIfNotExists();
     
 }
 public TableStorageRegistry()
 {
     var storageConnectionString = ConfigurationHelper.GetConfigValue<string>("StorageConnectionString");
     var storageClient = CloudStorageAccount.Parse(storageConnectionString);
     _client = storageClient.CreateCloudTableClient();
     _table = _client.GetTableReference(TableName);
     _table.CreateIfNotExists();
 }
        public TableUserIndexBuilder(CloudStorageAccount storageAccount, string userTableName, string userIndexTableName)
        {
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            _userTable = tableClient.GetTableReference(userTableName);
            _userIndexTable = tableClient.GetTableReference(userIndexTableName);

            _userIndexTable.CreateIfNotExists();
        }
        public TableHelper(string storageAccountConnectionString)
            : base(storageAccountConnectionString)
        {

            tableClient = base.StorageAccount.CreateCloudTableClient();
            mailingListTable = tableClient.GetTableReference(ConfigurationManager.AppSettings["TableMailinglist"]);
            mailingListTable.CreateIfNotExists();
        }
 public TableStorageManager(ConfigManager configManager, string tableName)
 {
     var storageAccount = configManager.GetStorageAccount();
     // Create the table client.
     var tableClient = storageAccount.CreateCloudTableClient();
     //create charts table if not exists.
     _cloudTable = tableClient.GetTableReference(tableName);
     _cloudTable.CreateIfNotExists();
 }
Example #29
0
        // inject cloudtable to the constructor
        public LearningHandler()
        {
            // creates the table client
            CloudTableClient tableLearning = _storageAccount.CreateCloudTableClient();

            // Create the CloudTable object that represents the "courses" table.
            _tableCourses = tableLearning.GetTableReference("courses");
            _tableCourses.CreateIfNotExists();
        }
Example #30
0
      /// <summary>
      /// Creates class instance
      /// </summary>
      /// <param name="storageAccountName">Storage account name</param>
      /// <param name="storageAccountKey">Storage account key</param>
      /// <param name="tableName">Target table name</param>
      public AzureTableLogWriter(string storageAccountName, string storageAccountKey, string tableName)
      {
         var creds = new StorageCredentials(storageAccountName, storageAccountKey);
         var account = new CloudStorageAccount(creds, true);

         CloudTableClient tableClient = account.CreateCloudTableClient();
         _table = tableClient.GetTableReference(tableName);
         _table.CreateIfNotExists();
      }
Example #31
0
        public void ListTablesWithPrefixExtended()
        {
            CloudTableClient tableClient = GenerateCloudTableClient();

            int    NumTables       = 50;
            int    TableNameLength = 8;
            int    NumQueries      = 100;
            string alpha           = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            string numerics        = "0123456789";
            string legalChars      = alpha + numerics;

            string            queryString = string.Empty;
            List <CloudTable> tableList   = new List <CloudTable>();
            List <CloudTable> localTestCreatedTableList = new List <CloudTable>();

            Random rand = new Random();

            try
            {
                #region Generate Tables

                // Generate Tables in Storage
                // This will generate all caps Tables, i.e. AAAAAAAA, BBBBBBBB....
                for (int h = 26; h < alpha.Length; h++)
                {
                    string tString = string.Empty;
                    for (int i = 0; i < TableNameLength; i++)
                    {
                        tString += alpha[h];
                    }

                    CloudTable table = tableClient.GetTableReference(tString);

                    if (table.CreateIfNotExists())
                    {
                        tableList.Add(table);
                        localTestCreatedTableList.Add(table);
                    }
                }

                // Generate some random tables of TableNameLength, table must start with a letter
                for (int m = 0; m < NumTables; m++)
                {
                    string tableName = GenerateRandomStringFromCharset(1, alpha, rand).ToLower() +
                                       GenerateRandomStringFromCharset(TableNameLength - 1, legalChars, rand).ToLower();

                    CloudTable table = tableClient.GetTableReference(tableName);

                    if (table.CreateIfNotExists())
                    {
                        tableList.Add(table);
                        localTestCreatedTableList.Add(table);
                    }
                }

                #endregion

                #region Generate Query Strings to cover all boundary conditions
                List <string> queryStrings = new List <string>()
                {
                    String.Empty, "aa", "zz", "az", "Az", "Aa", "zZ", "AA", "ZZ", "AZ", "z9", "a9", "aaa"
                };
                for (int k = 0; k < legalChars.Length; k++)
                {
                    queryStrings.Add(legalChars[k].ToString());
                }

                for (int n = 0; n <= NumQueries; n++)
                {
                    queryStrings.Add(GenerateRandomStringFromCharset((n % TableNameLength) + 1, legalChars, rand));
                }
                #endregion

                #region Merge Created Tables With Pre-existing ones
                int totalTables = 0;
                foreach (CloudTable listedTable in tableClient.ListTables())
                {
                    totalTables++;
                    if (tableList.Where((tbl) => tbl.Uri == listedTable.Uri).FirstOrDefault() != null)
                    {
                        continue;
                    }

                    tableList.Add(listedTable);
                }

                Assert.AreEqual(tableList.Count, totalTables);
                #endregion

                List <CloudTable> serviceResult = null;
                List <CloudTable> LINQResult    = null;

                try
                {
                    foreach (string queryValue in queryStrings)
                    {
                        queryString = queryValue;

                        serviceResult = tableClient.ListTables(queryString).OrderBy((table) => table.Name).ToList();
                        LINQResult    = tableList.Where((table) => table.Name.ToLower().StartsWith(queryString.ToLower())).OrderBy((table) => table.Name).ToList();

                        Assert.AreEqual(serviceResult.Count(), LINQResult.Count());

                        for (int listDex = 0; listDex < serviceResult.Count(); listDex++)
                        {
                            Assert.AreEqual(serviceResult[listDex].Name, LINQResult[listDex].Name);
                        }
                    }
                }
                catch (Exception)
                {
                    // On exception log table names for repro
                    this.testContextInstance.WriteLine("Exception in ListTablesWithPrefix, Dumping Tables for repro. QueryString = {0}\r\n", queryString);

                    foreach (CloudTable table in tableList)
                    {
                        this.testContextInstance.WriteLine(table.Name);
                    }

                    this.testContextInstance.WriteLine("Linq results =======================");

                    foreach (CloudTable table in LINQResult)
                    {
                        this.testContextInstance.WriteLine(table.Name);
                    }

                    this.testContextInstance.WriteLine("Service results =======================");

                    foreach (CloudTable table in serviceResult)
                    {
                        this.testContextInstance.WriteLine(table.Name);
                    }
                    throw;
                }
            }
            finally
            {
                // Cleanup
                foreach (CloudTable table in localTestCreatedTableList)
                {
                    // Dont delete Class level tables
                    if (createdTables.Where((tbl) => tbl.Uri == table.Uri).FirstOrDefault() != null)
                    {
                        continue;
                    }

                    // Delete other tables
                    table.DeleteIfExists();
                }
            }
        }