public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Function, "get",
                                                           Route = "ProcessTabularModel/{databaseName}/tables/{tableName}/partitions/{partitionName}")]
                                              HttpRequestMessage req,
                                              string databaseName,
                                              string tableName,
                                              string partitionName,
                                              TraceWriter log)
        {
            log.Info($"Received request to process specific partition in {databaseName}/{tableName}{partitionName} asynchronously.");

            try
            {
                SqlServerAnalysisServerTabular tabularModel = new SqlServerAnalysisServerTabular()
                {
                    ConnectionString = ConfigurationManager.ConnectionStrings["SsasTabularConnection"].ConnectionString,
                    DatabaseName     = databaseName ?? ConfigurationManager.AppSettings["DatabaseName"]
                };

                tabularModel.ProcessPartition(tableName, partitionName);
            }
            catch (Exception e)
            {
                log.Error($"Error processing partition - {databaseName}/{tableName}/{partitionName}: {e.ToString()}", e);
                return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }

            var successMessage = $"Successfully processed partition - {databaseName}/{tableName}/{partitionName}";

            log.Info(successMessage);
            return(req.CreateResponse(HttpStatusCode.OK, new { result = successMessage }));
        }
Пример #2
0
        public static void Run([QueueTrigger("%ProcessPartitionQueue%", Connection = "AzureWebJobsStorage")] string myQueueItem,
                               [Table("%ProcessPartitionStatusTable%", Connection = "AzureWebJobsStorage")] CloudTable statusTable,
                               TraceWriter log)
        {
            log.Info($"Received queue trigger to process partition : {myQueueItem}");

            QueueMessageProcesssTabular queueMessage = null;

            try
            {
                queueMessage = JsonConvert.DeserializeObject <QueueMessageProcesssTabular>(myQueueItem);

                SqlServerAnalysisServerTabular tabularModel = new SqlServerAnalysisServerTabular()
                {
                    ConnectionString = ConfigurationManager.ConnectionStrings["SsasTabularConnection"].ConnectionString,
                    DatabaseName     = queueMessage.Database ?? ConfigurationManager.AppSettings["DatabaseName"]
                };

                queueMessage.Status = "Running";
                queueMessage.ETag   = "*";
                TableOperation updateOperation = TableOperation.InsertOrReplace(queueMessage);
                statusTable.Execute(updateOperation);

                tabularModel.ProcessPartition(queueMessage.Tables, queueMessage.Parition);

                queueMessage.Status = "Complete";
                queueMessage.ETag   = "*";
                updateOperation     = TableOperation.InsertOrReplace(queueMessage);
                statusTable.Execute(updateOperation);
            }
            catch (Exception e)
            {
                log.Error($"Error occured processing partition - " +
                          $"{queueMessage?.Database}/{queueMessage?.Tables}/{queueMessage?.Parition} : {e.ToString()}", e);
                queueMessage.Status       = "Error Processing";
                queueMessage.ErrorDetails = e.ToString();
                queueMessage.ETag         = "*";
                TableOperation updateOperation = TableOperation.InsertOrReplace(queueMessage);
                statusTable.Execute(updateOperation);
            }

            log.Info($"Successfully completed partition processing for  {queueMessage?.Database}/{queueMessage?.Tables}/{queueMessage?.Parition}");
        }