call key vault from logic app and azure function

@Microsoft.KeyVault(SecretUri=https://my-key-vault.vault.azure.net/secrets/my-secret/29e8f1b62cb34f3aa40f0757aea0388d) 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(“https://login.microsoftonline.com/c1eb5112-7946-4c9d-bc57-40040cfe3a91/&#8221;); public static AuthenticationResultData GenerateToken(string clientId, string clientSecret, string resourceId) { string accessToken = string.Empty; AuthenticationResultData result = new AuthenticationResultData(); try { //var client = new RestClient(“https://login.microsoftonline.com/{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 => t.id == “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(“eu1ecoinstecuioth.azure-devices.net”, 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