Azure Function Archives -

Category Archives: Azure Function

Azure Integration with Dynamics 365 Finance & Operations

Introduction: Businesses in the digital age depend on cloud platforms and ERP systems integrating seamlessly. Dynamics 365 Finance & Operations (F&O) and azure integration is one such potent combination. Numerous advantages, such as improved scalability, agility, and data-driven decision-making capabilities, are made possible by this integration. The step-by-step instructions for connecting Azure with Dynamics 365 F&O will be provided in this blog. Steps to achieve the goal: Step 1: Setting up Azure Services a. Create an Azure account: Sign up for an Azure account if you don’t have one already. b. Provision Azure resources: Set up the required Azure resources such as virtual machines, databases, storage accounts, and other services according to your needs. Below are few links to create azure account. https://learn.microsoft.com/en-us/answers/questions/433827/how-to-get-an-azure-account-without-credit-card https://azure.microsoft.com/en-in/free/students Step 2: Configure Azure Active Directory (AAD) a. Click on New on the App Registration page. Set the name and set the type like below screenshots. b. Once you click on Ok button you would get notification like below. c. Now go to API Permission and click on Add permission d. Select Dynamics ERP e. Select Delegated Permission f. Select all permission and then click on Add Permission g. After selecting this permission again add permission on the screen this time selected Application Permission. h. Now we have to generate client secret value. Just select Certificates and secret. i. You will see the below screen where you can generate a new client secret j. Once you click on new you will see below screen where you can set the date to which this secret key would be valid. Max validity is 2 years. k. This is how the secret value would look like just copy Value. l. Now copy the Directory ID and Application ID Step 3: Connect Azure Services to F&O a. Go to Finance and Operations and serach globally Azure Active Directory/Microsoft Entra ID b. And then click on New and add your client id over here and set User ID as Admin. Please Note you should have the admin access right if not this won’t work. Conclusion: Azure integration with Dynamics 365 Finance & Operations empowers businesses to streamline processes, unlock data insights, and achieve operational excellence. Next blog would be how to connect standard API on postman and perform get and post function. Stay tuned! We hope you found this article useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com

Share Story :

Import an API and all its operations using its documentation in Azure API Management

Most of the time you would need to import an entire API collection with all of its supported operations to mask all of them or set policies on them. This can be easily done using Azure API management service. To start, log in to your Azure Portal, head over to the API management resource, and go to the API section on the left. From the options, select OpenAPI definition. Here I will use the Pet store API, https://petstore.swagger.io/ Go to the site or the site where your API stores the collection of all supported operations in JSON format. You can either have the JSON file of the collection or a website. In the OpenAPI specification put the link to your JSON collection or upload the JSON file and fill in the rest of the details and click on the Create button. You can see the list of operations appear. Hope you enjoyed this blog!

Share Story :

Create and deploy your first Azure Function using Visual Studio

In my previous blog, we created and deployed an Azure function using the Azure Portal itself. Now In this part of the blog, we will see how we can create and deploy Azure Function using Visual Studio. To proceed you would need ASP.NET and Azure Development extensions installed on top of your Visual Studio. If you haven’t had these installed you can go to Apps and features on your device and modify the installed program by selecting the change option instead of Uninstall. After installing these extensions, Create a new Project and search for Azure functions. Give the Project any desired name. Set the trigger for the function as HTTP. A sample piece of code will get loaded. In this scenario, I will modify the default code and write my custom logic, which adds two numbers. To run this logic, press F5 button on your keyboard and copy the URL, hitting this URL will trigger our function. Paste and run this URL in a web browser. As you can see on hitting the URL the function gets triggered and our two numbers get added in the output. Now we have to publish our function, it’s been working amazingly. Right-click on the Project Name and click on the Publish button. Select the target as Azure. Select Specific Target as Azure Function. Select the desired Function app instance or create a new one. Click on the final publish button. Wait for the function to successfully get deployed. Now we will check this in the Azure Portal and trigger it from there, Log in to the Azure account. You will find the recently deployed function in the left pane in the Functions section. Open this function and get its URL. Paste and run this URL in a web browser. You can see the output. Hope you understood the process of deploying serverless Azure functions using Visual Studio. Have a great day!

Share Story :

Create your first Azure Function using the Azure Portal

Learning serverless Azure Functions and deploying them, might sound like a daunting task. Azure functions are one of the most essential features of Microsoft Azure. In this article, we will see how we can create and deploy our first function using Azure Portal itself. In the next blog, I will also demonstrate how we can publish functions using visual studio. To start, login into your Azure Portal. Search for the Function app and click on create. Select desired resource group, give your function app a unique name, and fill in the rest of the options as required. After the deployment completes, open the resource. Go to the functions section on the left-hand pane. Click on the Create button. Select the “Develop in Portal” option as we are using Azure Portal to create our function. And select “HTTP trigger” now as we want to trigger the function using its API. Go to the “Code+Test” option, you’ll find a sample code. Change values in it for a personal response. You can also change the logic of the code from default. Here I am passing my name as Body in the request (input) section. As you can see based on the request body I have received a personified response. You can use the get function URL option and display desired output on hitting the URL. The output section in the default code is the last line “return new OKobjectResult(youroutput);” Hope you learned to deploy a function using the portal from this blog. Have a great day!

Share Story :

Secure your Environment Variable inside Azure Function using Key Vault

In the previous blog, we learn about how to use the Environment variable in Azure Function. Environment variables are most important and confidential as they might contain the system credentials or configure that you don’t want any to access directly. The most unsecure way to store them is directly inside the Configuration of Azure function so in this blog we will see how to store the Environment variable inside the Key Vault and use the Key Vault reference in Configuration. You can create an Azure function and use Environment Variable to do so do refer to my previous blog: Step 1: Create a Key Vault Login to Azure Portal and click on + Create a resource called “Key Vault”. Click on Create You can create a new resource group or select the existing group based on your preference. (You can create all resources related to a single project in one resource group so that it will easier to manage resources project wise) You need to set up the Access policy during the creation or after creating the Key Vault. We will set up an access policy for Azure Function later in the blog. Step 2: Set an Access policy for Azure Function. Open the Azure Function in which you want to use the reference of Azure Key Vault. Navigate to Identity Tab and toggle System assigned status to “ON”. Copy the Object (Principle) ID as we are going to use it during adding access policy. Open Azure Key Vault and Navigate to the Access Policies section. Click on + Add Access Policy We will only Add Get Permission in the Secret permissions section. You need to only add the permission that you want to allow your Azure Function can perform. Select the Principle User. Copy the Copied “Object ID” into search it will be easier to find it. Click on Add. Once you will add a resource in the access policy, it will allow your resource (Azure Function) to perform a Get operation on all the secrets from Key Vault. Do not forget to Save after you add the policy. Step 3: Add Secret and Configure it inside Azure Function Navigate to the Secrets section and Click on + Generate/Import Enter the Name and Value(Credentials/Configuration) Open the current version and Copy the secret URL as it will be required while configuring the Reference. Navigate to the Configuration section of Azure Function. Change the Configuration and add the KeyVault Reference as below: @Microsoft.KeyVault(SecretUri=<Copied SecretURL>) Do not forget to Save after changing the configuration Step 4: Testing using Postman We will require the API testing tool, here I am using Postman and the following is the link to download “Postman”. https://www.postman.com/downloads/ Copy the Function URL and send a post request. As result, you will notice the username is coming from KeyVault as we have to change the configuration. Conclusion: This is how you can secure your Environment Variable using Azure KeyVault. You can set up multiple KeyVault for different deployment and access policies depending on the requirement. When you are storing the Credentials and Configuration in KeyVault, you just need to set up the Access policy. All configuration is managed by the Azure Admin and if origination has a policy that they don’t want to share the credentials they can follow this process and only share the KeyVault URL with the developer so that they only need to configure it.

Share Story :

How to call logic app in Azure function app

In this blog, we will see how we can trigger the logic app using the azure function app. Let’s start with creating a logic app (HTTP triggered) that sends an email when the logic app URL is hit in the function app. Step 1: Create a logic app resource and start by adding an HTTP GET request trigger. Url will auto-generate after saving the logic app. Step 2: Add send email block after that to receive an email Step 3: now create a function app in visual studio by creating a new project. Step 4: Add project name and now select type of function app, select the create option Step 5: Add the below code to the auto-generated code template in the visual studio Step 6: Run the function locally. then you will get URL in the command prompt copy that and paste it into your browser. Step 7: After entering the URL you should receive an email as mentioned in the logic app. In this way, the logic app triggered successfully using the function app Hope this blog helps you. Thank you!!

Share Story :

Use of Environment Variable inside Azure Function in C#

In this blog, we will learn how to configure and use Environment Variable in Azure Function. Concept of using Environment variable during your development which needs to deploy on multiple servers and connect to multiple systems. Whenever you use Environment variables to store the global constant or system credentials it reduces the time which was required to modify the code base for multiple deployments. Let’s get started with Creating the Azure Function and using the Environment variable. Step 1: Create an Azure Function inside the Visual Studio: I have created the HTTP Trigger Azure function inside Visual Studio and the authorization level is Anonymous Once you create an Azure Function project you will notice there are many files created with the project.  We have a “local.setting.json” file that we are going to use and it holds the environment variable while the development and testing phase of your Azure function. Step 2: Declare credentials/global variable inside “local.setting.json” Information on local.setting.json – This file represents your local application setting for your Azure Function and it stays with your local build only. While you publish your azure function to Azure Portal or commit your code to your Repo this file is never pushed to the server as they are excluded/prevent from committing or publishing. Step 3: Access variable inside the code You can access the environment variable using the Environment class(required System lib). Based on your preference you can either access Environment variable the directly inside the code or you can create a CONSTANT class as mentioned below screenshot. Here, I am passing this environment variable inside a response so that we can test it. Step 4: Testing using Postman We will require the API testing tool, here I am using Postman and the following is the link to download “Postman”. https://www.postman.com/downloads/ To test the application, click on the Start button on top of the Navbar as mentioned below in the screenshot [Button will have Project Name]. It will take a few minutes to Load the Azure Emulator Following is the screen you will be able to see and copy the URL highlighted in the red below and paste that URL into Postman. Result: Now, you need to configure the Environment while deploying the Azure function on Azure Portal, and below are steps for the same: Step 1: Deploy an Azure Function on Azure Portal. You can directly create it on Portal or you can create it from Visual Studio. Here I am going to create and deploy it from Visual Studio: Right Click on the project and select Publish: Select Azure and Click on Next: Click on the + icon to create a new function, You can use the existing resource group or create a new resource group as per your preference: After deployment is completed you can see the deployed Azure function on Azure Portal: Now, if you try to use the Azure Function URL and post the request then you will notice that all the environmental credentials part is missing as we have not configured the environment variable on the Azure portal inside Azure Function App: Step 2: Configure the App Environment variable on Azure Portal for online deployment. Navigate to the Configuration section of your deployed Azure Function Add the Application setting in your Configuration and the Name should same as you have declared in your local.setting.json file. Make sure your click on Save to update the configuration on Portal. After configuration if you test your deployed Azure function using postman you will get your expected result: This is how you can configure and use the Environment variable inside your Azure Function. It will make your life easier while deploying Azure on Development, UAT, or Production Environment. You can store the Source and Destination system credentials, SQL Access credentials, or Custom Global Variable based on your business requirement of integration.

Share Story :

Let’s get started with Azure Function for Dynamics 365 CRM: Part 2 [Cloud Deployment]

In the previous blog, we have learned how to create an azure function to connect with Dynamics 365 CRM and create an account record whenever an azure function is triggered by the HTTP request. [Link]. In this blog, we will learn how to deploy the Azure Function App to Azure Cloud so that we can trigger that function anywhere. Prerequisite 1. Microsoft Azure Account 2. Active Subscription [Create a Free trial or Pay-as-you-Go Subscription] If you are creating an azure function for learning purposes, then go with Free Trial but if you are working on the development for your organization or client then go for a Pay-as-you-Go subscription. Step 1: Create a resource on Azure Portal for Azure Function Deployment. Login to the portal.azure.com with your account and click on Create a resource: Create a resource for Function App as mentioned below screenshot: Here we will create a new resource group but If you don’t have any existing resources. Following are configuration details that you need to fill during the creation of the resource. Function Name: It is a global URL to access the Azure Function App and it must be unique. Publish: You can directly publish your code or use Docker Container for publishing your Azure function Runtime stack: Here we are building the .net application so we will choose .Net as our Runtime stack to support Azure Function. We have multiple options we can create an azure function for Nodejs, Python, Java, Powershell core or you can use customer handler. After configuration are you ready to click on “Review and Create” It will take a few minutes to create and deploy the Azure Function App in the cloud. Step 2: Publishing the Azure Function from Visual Studio: Open the Azure Function project in Visual studio. Right-click on the Project and click on the Azure. You will get the below screen on that we need to click on the Start. Now we will choose Azure as we are deploying the Azure Function on the Azure Cloud and click on Next: Once you select the azure then it will open the configuration screen. In the configuration window, you need to log in with Azure Account with Active Subscription. Select the resource group and select the function app as mentioned below screenshot. After the configuration is finished click on Publish. It will take a few minutes to deploy the application to the cloud. Step 3: Get Azure Function URL from Azure Portal. Open newly create Function App in the Azure portal app and click on the Function App: You will find the function1 has been deployed. Click on that function to open it. To Get the Function URL click on the Get Function URL and copy the URL. Testing We will require the API testing tool, here I am using Postman and the following is the link to download “Postman”. https://www.postman.com/downloads/ Open the Postman and click on the create a new tab. Select request as POST and paste the URL: After pasting the URL, click on Send: Now, we will take look at Dynamics 365 CRM environment and check whether the account is created or not. Before After: Stay Tuned for the next Blog. In the next blog, we will create a Contact Us form in HTML and post data using Azure Function Dynamics 365 CRM to store the responses from your website. External Links: Azure Function Pricing: https://azure.microsoft.com/en-in/pricing/details/functions/

Share Story :

Integrated Security Used in Azure Function

Azure Functions Azure Functions is a serverless compute service that enables you to run code on-demand without having to explicitly provision or manage infrastructure. · Integrated security — Protect HTTP-triggered functions with OAuth providers such as Azure Active Directory, Facebook, Google, Twitter, and Microsoft Account. Azure function has function access key mechanism which provide security to access the endpoint. Function have different level of access level. Like Function, Anonymous, Admin. General Security Flow of the Azure Function In this, Azure AD, Managed Identities, Key Vault, VNET and firewall rules are used. To create dedicated and isolated Azure Functions, it can also be decided to create a separate App Service Environment (ASE). However, an ASE can be difficult to manage and more costs are involved.  How to Secure Storage Account of Azure Function Provide Security to Request and Response Provide Security to Database keys provide a default security mechanism; you may want to consider additional options to secure an HTTP endpoint in production. For example, it’s generally not a good practice to distribute shared secret in public apps. If your function is being called from a public client, you may want to consider implementing another security mechanism. Authorization scopes (function-level) There are two access scopes for function-level keys: Function: These keys apply only to the specific functions under which they are defined. When used as an API key, these only allow access to that function. Host: Keys with a host scope can be used to access all functions within the function app. When used as an API key, these allow access to any function within the function app. Each key is named for reference, and there is a default key (named “default”) at the function and host level. Function keys take precedence over host keys. When two keys are defined with the same name, the function key is always used. Master key (admin-level) Each function app also has an admin-level host key named _master. In addition to providing host-level access to all functions in the app, the master key also provides administrative access to the runtime REST APIs. This key cannot be revoked. When you set an access level of admin, requests must use the master key; any other key results in access failure. System key Specific extensions may require a system-managed key to access webhook endpoints. System keys are designed for extension-specific function endpoints that called by internal components. For example, the Event Grid trigger requires that the subscription use a system key when calling the trigger endpoint. Durable Functions also uses system keys to call Durable Task extension APIs. Authentication/authorization While function keys can provide some mitigation for unwanted access, the only way to truly secure your function endpoints is by implementing positive authentication of clients accessing your functions. You can then make authorization decisions based on identity. Enable App Service Authentication/Authorization The App Service platform lets you use Azure Active Directory (AAD) and several third-party identity providers to authenticate clients. Security in App Service App service is used to secure Function app by using built in App Service features. When you create App in default domain of the Azure like <app_name>.azurewebsites.net which is by default secure with the HTTPS in addition if you secure your app using custom domain you can also provide SSL/TLS level of security. Following are the certificates supported by App service. Free App Service Managed Certificate App Service certificate Third-party certificate Certificate imported from Azure Key Vault

Share Story :

Let’s get started with Azure Function for Dynamics 365 CRM: Part 1

In this blog, we will learn how to create an Azure Function App to connect it with Dynamics 365 CRM and perform the CRUD operation in Dynamics 365 CRM. First, we will create an Azure Function project for Dynamics 365 CRM from Visual Studio, and below are the steps for the same. Open Visual Studio and create a new Azure Function Project. Filter platform as Azure, select Azure Function, and click on Next. Name your project and click on Create button. After clicking on Create, you will get the below screen where you need to select the Trigger and Azure Function v1 (.Net Framework) and click on Create. In my case, the Azure Function trigger will be Http Trigger which means when an azure function will receive an HTTP request it will trigger. Your Azure Project will be created and the following will be the structure of the project. Now, we will create Azure Function to connect with the Dynamics 365 CRM we need to add the required NuGet Package [Microsoft.CrmSdk.CoreAssemblies]. To add the NuGet Package right-click on the Project and click on Manage Nuget packages. Add Microsoft.CrmSdk.CoreAssemblies in your Project. Following is the code to connect the Dynamics 365 CRM. Currently, we are going to use the credential by specifying them in the C# Code or you can use it as constant. Later in the series, we will learn how to use Environment Variable and pass the credential more secure way in Azure Function using Azure Key Vault. [Stay tuned..!!] Now, select the code and Refactor the code and make the connection function that will return the IOrganizationService if the connection is established else return null. Now, the final code will be as below: Now, we will create a customer with a Hardcoded name when the function is triggered with an HTTP request. Update the existing code with the below code: Testing: We will require the API testing tool, here I am using Postman and the following is the link to download “Postman”. https://www.postman.com/downloads/ To test the application, click on the Start button on top of Navbar as mentioned below in the screenshot [Button will have Project Name]. It will take a few minutes to Load the Azure Emulator Following is the screen you will be able to see and copy the URL highlighted in the red below and paste that URL in Postman. Open the Postman and click on the create a new tab; Select request as POST and paste the URL: After pasting the URL, click on Send You will get the following response on the Azure Function Tool and Postman If there any error or issue with the Azure Function code, the request will be failed and will be displayed on both Azure Function Tool and Postman [Status will be “4**” or “5**” ] Now, we will take look at Dynamics 365 CRM environment and check whether the account is created or not. We are justing getting started with Azure Function for Dynamics 365 CRM and stay tuned for more in this series. Upcoming blogs 1. How to use Dynamics 365 Credentials securely using Azures Function. 2. How to create Dynamics 365 integration with Third-party Applications. Many more……

Share Story :

SEARCH BLOGS:

[gravityform id="36" ajax="true"]

FOLLOW CLOUDFRONTS BLOG :