Guest User

Untitled

a guest
Jan 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. using Microsoft.Azure.WebJobs;
  2. using Microsoft.Azure.WebJobs.Host;
  3. using Microsoft.ServiceBus.Messaging;
  4. using Microsoft.Azure;
  5. using Microsoft.WindowsAzure.Storage;
  6. using Microsoft.WindowsAzure.Storage.Table;
  7. using Newtonsoft.Json.Linq;
  8. using System.IO;
  9. using System.Runtime.Serialization.Json;
  10. using System.Text;
  11. using System.Runtime.Serialization;
  12. using Newtonsoft.Json;
  13. using System.Collections.Generic;
  14.  
  15. namespace FidoHistory
  16. {
  17. public static class FidoHistoryFunction
  18. {
  19. [FunctionName("HistoryPublisher")]
  20. public static void Run([ServiceBusTrigger("fidoscattersearch", "mysubscription", AccessRights.Manage, Connection = "conn")]string msg, TraceWriter log)
  21. {
  22. log.Info($"C# ServiceBus topic trigger function processed message: {msg}");
  23. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
  24. CloudConfigurationManager.GetSetting("storageacct"));
  25.  
  26. // Create the table client.
  27. CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
  28.  
  29. // Retrieve a reference to the table.
  30. CloudTable table = tableClient.GetTableReference("REQUESTS");
  31. log.Info("NAME-> "+table.Name);
  32. // Deserialization from JSON
  33.  
  34.  
  35. RequestEntity obj = JsonConvert.DeserializeObject<RequestEntity>(msg);
  36. log.Info("ParitionKey->"+obj.PartitionKey);
  37. obj.json = msg;
  38.  
  39. TableOperation insertOperation = TableOperation.Insert(obj);
  40.  
  41. // Execute the insert operation.
  42. table.Execute(insertOperation);
  43.  
  44. }
  45. }
  46. }
  47.  
  48.  
  49.  
  50. public class RequestEntity : TableEntity
  51. {
  52. private string cid;
  53. private string sid;
  54. private string payload;
  55.  
  56. public string correlationId
  57. {
  58. get { return cid; }
  59. set {
  60. cid = value;
  61. this.RowKey = value;
  62. }
  63. }
  64. public string storeId
  65. {
  66. get { return sid; }
  67. set {
  68. sid = value;
  69. this.PartitionKey = value;
  70. }
  71. }
  72.  
  73. public string json
  74. {
  75. get { return payload; }
  76. set { payload = value; }
  77. }
  78. }
Add Comment
Please, Sign In to add comment