Skip to content

Instantly share code, notes, and snippets.

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;
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");
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));
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);
}