This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Net; | |
using System.Net.Http; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Azure.WebJobs.Extensions.Http; | |
using Microsoft.Azure.WebJobs.Host; | |
using Newtonsoft.Json; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log.Info("Adding Headers for Update Activity"); | |
client.DefaultRequestHeaders.Add("AS-MainActivityId", mainActivityId); | |
client.DefaultRequestHeaders.Add("AS-StageActivityId", stageActivityId); | |
client.DefaultRequestHeaders.Add("AS-Status", "Success"); | |
client.DefaultRequestHeaders.Remove("AS-ArchiveMessage"); | |
log.Info("Successfully Added Headers"); | |
var updateActivityUri = new Uri(req.RequestUri.AbsoluteUri.Replace(req.RequestUri.PathAndQuery, "/api/UpdateActivity")); | |
log.Info("Calling update Activity"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var startActivityUri = new Uri(req.RequestUri.AbsoluteUri.Replace(req.RequestUri.PathAndQuery, "/api/StartActivity")); | |
var activityContent = new ActivityContent() | |
{ | |
MessageBody = httpContent.ReadAsStringAsync().Result, | |
MessageHeader = httpContent.Headers.ToDictionary(s => s.Key, s => s.Value) | |
}; | |
var json = JsonConvert.SerializeObject(activityContent, Formatting.Indented); | |
var startActivityResponse = await client.PostAsync(startActivityUri, new StringContent(json)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = new HttpClient() | |
client.BaseAddress = new Uri("https://api.coindesk.com/v1/bpi/currentprice.json"); | |
var result = await client.GetAsync(""); | |
var resultContent = await result.Content. ReadAsAsync<JObject>().Result; | |
var token = resultContent["bpi"]["USD"]["rate_float"]; | |
var price = (int)token; | |
if (price > 6000) { | |
log.Info(“Price is higher than the threshold value” + price); | |
} |