Utilizing Configuration With Azure Perform



Generally we have to retailer configuration knowledge in our Azure Perform which we will reference.  In our Azure Perform, this configuration knowledge consists of storing server urls, connection strings, credentials and many others. That is very helpful after we wish to deploy our Azure perform in numerous environments. We don’t must do any modifications in our Azure perform code, we will merely use Configuration to carry new particulars and our Azure perform might be utilizing the brand new particulars. Let’s see how we will use configuration in Azure perform.



This text assumes you may have a fundamental understanding of the Azure perform and tips on how to work with it. If you’re new to the Azure perform, you may discuss with the small print right here. Again to our subject. Let’s say we’ve a requirement to retailer our software consumer particulars and different settings which we want in our perform app to attach with Dynamics 365 CE. To retailer this data we have to use two steps:
  1. Replace your Azure perform to make use of ConfigurationManager.AppSetting
  2. Add all of the Azure perform settings in Azure Portal

Let’s  say we wish to use software settings for blob container identify and for the weblog connection particulars. The very first thing we have to do is add reference to System.Configuration in our Azure perform, and after that we will use the next code.

  1. var BlobConnection = ConfigurationManager.AppSettings[“BlobConnection”];  
  2. var Containername =  ConfigurationManager.AppSettings[“Containername”];  

Within the above code we’re utilizing two Keys, BlobConnection and Containername. We have to add configuration in Azure perform utilizing the identical key names. Equally we will use different keys in different strategies, for instance, within the  beneath methodology we’re utilizing it to get related with Dynamics 365 CE.

  1. non-public static OrganizationWebProxyClient GetCRMService(TraceWriter log)  
  2.        {  
  4.            var aadInstance = “”;  
  5.            var organizationUrl = ConfigurationManager.AppSettings[“Dynamics365URL”];  
  7.            var clientId = ConfigurationManager.AppSettings[“ClientId”];  
  8.            var clientkey = ConfigurationManager.AppSettings[“Clientkey”];  
  9.            var tenantId = ConfigurationManager.AppSettings[“TenantId”];  
  12.            var clientcred = new ClientCredentials(clientId, clientkey);  
  14.            var authenticationContext = new AuthenticationContext(aadInstance + tenantId);  
  16.            var authenticationResult = authenticationContext.AcquireTokenAsync(organizationUrl, clientcred);  
  18.            var requestedToken = authenticationResult.Consequence.AccessToken;  
  19.            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;  
  20.            var sdkService = new OrganizationWebProxyClient(GetServiceUrl(organizationUrl), new TimeSpan(30, 0, 0), false);  
  21.            sdkService.HeaderToken = requestedToken;  
  23.            return sdkService;  
  25.        }  

Now we’ve the code, we will add configuration settings utilizing Azure portal after deploying our Azure perform. Use the next steps,

  1. Open your Perform App
  2. Underneath your Perform App setting click on on the Configuration

  3. Click on on New software setting

  4. Add all of the Key- Values one after the other

  5. As soon as all of the configuration is added,  click on on the Save button to save lots of your configuration.

Restart your perform app and it ought to refer all of the configurations you added.

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button