Saturday, March 26, 2022

How to create record in dcrm using azure function

 Step 1. Go to https://portal.azure.com/

 Step 2. Create the App Registration. Just provide Name and click on Register. 




Step 3.  Once you create the App Registration then click on the certificate and secrets and click on the new and provide the description and expire date pleases see the screenshot.



Now just copy the client secret value because after 10 minutes you will not able to see the entire value please make sure you copy your client value.

Step 4. Now give the API Permission in App Registration click on the add permission and select the dynamic CRM then choose the delegate one and check the user_immersion then click on add permission please see the below screenshot.


If you are thinking why we are creating App Registration please flow the below link 
 

Step 5. Now create the Application User. Go to power platform admin center and create the application user please follow the step you will be able to Create it.

                                                                                           

Now you set up the application user. Now you can create the code in visual studio and do the operations like create, update, delete etc. in DCRM.                                                                                                    

Step 6. Now open the visual studio create new project search the Azure Function and select the               
Right click on the project and install the nuget package a. Microsoft.PowerPlatform.Dataverse.Client b. Crmsdk.coreAssembly. install the both the package and provide the Directories.                                     
Step 7.Now copy paste the code in visual studio.                                                                                       
                                                                                            
  • using System;
  • using Microsoft.Azure.WebJobs;
  • using Microsoft.Azure.WebJobs.Host;
  • using Microsoft.Extensions.Logging;
  • using Microsoft.PowerPlatform.Dataverse.Client;
  • using Microsoft.Xrm.Sdk;

  • namespace Timer_Trigger
  • {
  •     public static class Function1
  •     {
  •         [FunctionName("Function1")]
  •         public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log)
  •         {
  •             log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
  •             Connect();
  •             Entity e = new Entity();
  •         }
  •         public static void Connect()
  •         {
  •             //  log.LogInformation("C# HTTP trigger function processed a request.");
  •             ServiceClient crmServiceClient = null;
  •             System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
  •             var clientId = "8182544c-3485-4bc3-9884-81617d48e39a";
  •             var clientSecret = "8jm7Q~nhPHGP0Ccl-6a5ow2Tivf4LzADLdZMR";
  •             var organizationUrl = "https://org13ffb2c4.crm8.dynamics.com/";
  •             string connectionString = "Url=" + organizationUrl + "; " +
  •             "AuthType=ClientSecret; " +
  •             "ClientId= " + clientId + "; " +
  •             "ClientSecret=" + clientSecret;

  •             crmServiceClient = new ServiceClient(connectionString);
  •             if (crmServiceClient.IsReady)
  •             {

  •                 CreateRecord(crmServiceClient);

  •             }
  •         }
  •         private static void CreateRecord(ServiceClient crmServiceClient)
  •         {
  •             try
  •             {
  •                 Entity newAccount = new Entity("account");
  •                 newAccount["name"] = "Account is crated through Azure";
  •                 crmServiceClient.Create(newAccount);

  •                 //Write the program here


  •             }
  •             catch (Exception)
  •             {

  •                 throw;
  •             }
  •         }
  •     }
  • }
 put the debugger on the Gary side of visual studio 






                                    







What is the use of app registration in azure

 1. Apps Register in Azure AD  provide you Application Id and Redirect URI value that Independent Software Vendor can use in their client application authentication code.

2. Using App Registration we can generate the token and authenticate the application.

3. If we want to use Azure Active Directories capabilities we must register the App.

4. Once you create App Registration you will get client ID and Secret Key and you can also provide the permission as well from app Registration. 

  

Friday, March 4, 2022

Overview Of Azure Function

Scenario: If you want to build the application before that you have to choose the framework then we need to learn how to deploy the framework onto the server then how to manage and maintain those server over time. It is not easy quick or efficient that is way we go for azure function.

Azure Function : It is easy way to build the application that you need using serverless function that scale automatically meet the requirement(Demand) no worrying about server and infrastructure.

If you are new to development then azure function help you to create application that accept http request for website processes product order via queue message react to data flowing from device like an IOT hub or just run simple schedule task since as your function scale automatically just write the function logic as your function that handle the rest of the things like Deployment, Maintenance so that your application running smooth.

You are paying only what you use.

You will write less code.

Manage less infrastructure 

Upfront cost(Purchasing is very easy for your own things) is very less. 

Notes: Let's assume your task is running and performing critical task.

for example building API or managing the message queue.

First Thing : Azure Function allow you to implement your system logic into available coed blocks and these code blocks are called as function. you can call the function at anytime if you want to response the critical task. 

Second Things : If the request is increase as azure function meet the requirement. If sometime request fall then automatically extra resource drop off. 

Where do all compute resource come automatically : Azure Functions hosting options 

What we can do with azure function :

Azure functions are best suited for small apps that contain event that can work independently for other websites. Some of the common azure functions are: scheduling the task, sending the mail, sending the notification, IoT data processing task, database cleanup, take the backup, order task executing, message.

What is trigger or event to run azure function :

Trigger is an object that tell to the azure function who it will be invoked.

If you want to execute a function every 5 minutes then you have to use timer trigger. 

Every function must be associate with one trigger.

Based on the task we have different types of trigger :

1. Timer Trigger (Execute a function based on scheduling task).

2. HTTP Trigger(Execute a function when HTTP request receive).

3. Blob  Trigger(EAF When file is uploaded or modified in azure blob storage).

4. Queue Trigger(EAF When message added into azure storage queue).

5. Azure Cosmos DB.

6. Event Hub.

 



How to create record in dcrm using azure function

 Step 1. Go to  https://portal.azure.com/  Step 2. Create the App Registration. Just provide Name and click on Register.  Step 3.  Once you ...