call key vault from logic app and azure function

@Microsoft.KeyVault(SecretUri= Azure function – using Microsoft.Azure.KeyVault; using Microsoft.Azure.WebJobs; using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.Azure.WebJobs.Host; using Microsoft.IdentityModel.Clients.ActiveDirectory; using System.Configuration; using System.Net; using System.Net.Http; using System.Threading.Tasks; namespace KeyVaultManagementFunctionApp {     public static class Runkva     {         [FunctionName(“demo”)]         public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, “get”, “post”, Route =”HttpTriggerCSharp/vault/{vaultname}/secret/{secret}”)]HttpRequestMessage req, stringvaultname, string secret, TraceWriter log)         {             // The Application Id of the Azure AD application             var clientId = ConfigurationManager.AppSettings[“ClientId”];             // The Value of the Key you created in the Azure AD application             var clientSecret… Read More call key vault from logic app and azure function

read blob data

private async Task<string> GetBlobMessage(string deviceType, ReplayMessage replayMessage, string connectionString, Models.Platform platformDetails) { string userName = HttpContext.User.Identity.Name; Microsoft.Azure.Devices.Device device; registryManager = RegistryManager.CreateFromConnectionString(connectionString); string year = replayMessage.Year.ToString(); string date = String.Format(“{0:D2}”, replayMessage.Date); string month = String.Format(“{0:D2}”, replayMessage.Month); string hour = String.Format(“{0:D2}”, replayMessage.Hour); telemetry.TrackEvent(“BlobMessage started “); //string time = month + “/” + date + “/” + year… Read More read blob data

Signal R with .NET

public class NotificationSend : Hub { private static IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<NotificationSend>(); public override Task OnConnected() { string name = Context.User.Identity.Name; Groups.Add(Context.ConnectionId, name); return base.OnConnected(); } public void SendToUser(string messageText,string userName) { hubContext.Clients.Group(userName).Notification(messageText); } public void StopLoader(string messageText, string userName) { hubContext.Clients.Group(userName).Stoploader(messageText); } } $(function () { var notification = $.connection.notificationSend; console.log(notification); notification.client.Notification = function… Read More Signal R with .NET

Rest Client example execute api POST and DELETE oauth url generate token

public class HttpClientHelper { private static HttpClient httpClient = new HttpClient(); private static RestClient client = new RestClient(“;); public static AuthenticationResultData GenerateToken(string clientId, string clientSecret, string resourceId) { string accessToken = string.Empty; AuthenticationResultData result = new AuthenticationResultData(); try { //var client = new RestClient(“{tenant-id}/”); var request = new RestRequest(“oauth2/token”, Method.POST); request.AddHeader(“Content-Type”, “application/x-www-form-urlencoded”); request.AddParameter(“grant_type”, “client_credentials”); request.AddParameter(“resource”,… Read More Rest Client example execute api POST and DELETE oauth url generate token

update cosmos db document with new values c#

class Program { static void Main(string[] args) { NewMethod().Wait(); } private static async Task NewMethod() { try { var client = new DocumentClient(new Uri(“uri”), “key”); //Fetch the Document to be updated var doc = client.CreateDocumentQuery<RootObject>(UriFactory.CreateDocumentCollectionUri(“Db-dev”, “collection”)) .Where(t => == “id”).AsEnumerable() .FirstOrDefault(); List<string> ok = new List<string>() { “d1”, “d2” }; doc.DevicesList.AddRange(ok); //update document var… Read More update cosmos db document with new values c#

register device on iothub bulk import and send data

class Program { static RegistryManager registryManager; static string connectionString = “iothub-connection”; static void Main(string[] args) { //Task t1 = senddata(); //t1.Wait(); //Task t1 = BulkImport(); //t1.Wait(); } private static async Task senddata() { try { DeviceClient deviceClient = DeviceClient.Create(“”, new DeviceAuthenticationWithRegistrySymmetricKey(“deviceid”, “device-key”), Microsoft.Azure.Devices.Client.TransportType.Mqtt); while (true) { await deviceClient.SendEventAsync(new Microsoft.Azure.Devices.Client.Message() { MessageId=””}); } } catch (Exception… Read More register device on iothub bulk import and send data

Creating A Simulated Device For IoT Hub Using .NET

This article is in continuation of my previous article and here, I am going to create two console applications on the same project and use the Hostname and access keys to connect with these two applications that send the message to each other using the IoT hub that demonstrates the IoT connection between the two combined IoT devices. Prerequisites… Read More Creating A Simulated Device For IoT Hub Using .NET

Azure function basic code

#r “Newtonsoft.Json” using System.Net; using Newtonsoft.Json; using System.Text; public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) { try { log.Info(“C# HTTP trigger function processed a request.”); var data = await req.Content.ReadAsStringAsync(); var json = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(data); json.Remove(“etag”); return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(json.ToString(), Encoding.UTF8, “application/json”) }; } catch (Exception ex) { HttpResponseMessage res =… Read More Azure function basic code

Get insert Id from stored proc sql using OUTPUT

ALTER PROCEDURE sp_Mydemo — Add the parameters for the stored procedure here @Name nvarchar (520), @Date nvarchar (520), AS BEGIN insert into data.MyTable (Name,Date) OUTPUT INSERTED.Id values (@Name,@Date) END GO call sp – DECLARE @Name nvarchar (520) = ‘test’; DECLARE @Date nvarchar (520)= ‘2018-03-22 14:57:41.687’; exec sp_Mydemo @Name , @Date it will return new GUID… Read More Get insert Id from stored proc sql using OUTPUT