{Quick Tip} Azure Function deployment error “ERROR_CERTIFICATE_VALIDATION_FAILED”

Today while deploying Azure Function into a new environment I got this error:

Web deployment task failed. (Connected to the remote computer (“https://mytestfunapp.azurewebsites.net/ “) using the specified process (“Web Management Service”), but could not verify the server’s certificate. If you trust the server, connect again and allow untrusted certificates.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_CERTIFICATE_VALIDATION_FAILED.) [C:\Users\3176\source\repos\Solution\Integration_Functions.csproj]


This error is not limited to Azure or Azure Functions. It occurs if SSL certificate is invalid or not configured correctly. To allow untrusted certificates we will need to set <AllowUntrustedCertificate>True</AllowUntrustedCertificate> in *.pubxml

Ftp to CRM using Azure Function


New to Azure Function?

Function is serverless offering form Azure. Serverless computing is a way to write code without need to manage infrastructure, application dependencies and other required resources. Even for scaling Azure will take care of them. Once we know the environment using Function is easy, login to Azure portal write or deploy code and start using it.

An Azure function is simply a function written in C#, Java, JavaScript, F#, Python or PHP. A function can be executed manually or scheduled to run automatically. The third way to execute a function is through triggers. A trigger can be another Azure service or something which has no link with Azure. Some Azure services which can trigger a function are Cosmos DB, Event Hubs, App Service, Storage queues, blobs, Service Bus queues or topics. Functions are also available for Logic Apps, Power Apps, Microsoft Flow and outside Azure over HTTP.

About Demo

This function will be scheduled to run once in 24 hours. From ftp server it will read a CSV file (data for lead entity) and pass it to CRM. Functions can be coded and published from Visual Studio or directly in Azure portal, for this demo I will use later approach.


Create Function App and Function

To create a function we need to create a function app. If you don’t want to use existing resource group and storage feel free to create new.

Open function app and add a function in it:

In Schedule add 0 0 12 * * *. This cron expression will trigger this function in midnight at 12 O’clock. See this for more details about cron expression.

App Settings

Let’s add CRM connection string, FTP URL and credentials as application settings to avoid hard coding.

Sample of application settings:

Key Value Comments
FtpId UserId  Ftp account user id
FtpPassword P@ssword  Ftp account password
FtpAddress  ftp://ftp.domain.com/full.csv Ftp address with file name
Connectionstring AuthType = Office365; Url = https://crminstace.crm6.dynamics.com/;



This is example with Dynamics 365, no need to surround with single or double quote.



using System;
using System.Configuration;
using System.IO;
using System.Net;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Tooling.Connector;
public static void Run(TimerInfo myTimer, TraceWriter log)
log.Info($”Execution Started. : {DateTime.Now} “);
Stream fileStream = null;
string[] fileContentToWriteToCRM;
IOrganizationService org;
string ftpId = ConfigurationManager.AppSettings[“Ftpid”].ToString();
string ftpAddress = ConfigurationManager.AppSettings[“ftpAddress”].ToString();
string ftpPassword = ConfigurationManager.AppSettings[“ftpPassword”].ToString();
#region Read Ftp File(s)
FtpWebRequest ftpReq = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create(ftpAddress);
ftpReq.Credentials = new NetworkCredential(ftpId, ftpPassword);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ftpReq.EnableSsl = false;
WebResponse tmpRes = ftpReq.GetResponse();
fileStream = tmpRes.GetResponseStream();
#region ProcessData
TextReader tmpReader = new StreamReader(fileStream);
var txtData = tmpReader.ReadToEnd();
fileContentToWriteToCRM = txtData.Split(new string[] { “\r\n” }, StringSplitOptions.RemoveEmptyEntries);
#region CRM Data Posting
string connectionstring = ConfigurationManager.AppSettings[“connectionstring”];
CrmServiceClient conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(connectionstring);
org = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;
log.Info($”CRM connection established”);
log.Info($”Looping to move data to CRM”);
foreach (var row in fileContentToWriteToCRM)
var rowvalues = row.Split(‘,’);
Entity lead = new Entity(“lead”);
lead.Attributes[“subject”] = rowvalues[0].ToString();
lead.Attributes[“firstname”] = rowvalues[1].ToString();
lead.Attributes[“lastname”] = rowvalues[2].ToString();
var id = org.Create(lead);
log.Info($”Lead created in CRM with GUID : {id} “);
log.Info($”Loop Ended moved all data to CRM “);

Adding Dependencies

Since code use assemblies from CRM SDK, we will add these to our code. With Azure Function it is achieved using project.json file. Add project.json file if it is not already there and then add NuGet packages in it.



“frameworks”: {
“dependencies”: {
“Microsoft.CrmSdk.CoreAssemblies”: “”,
Let’s save it, run the function if it is not already running and see how we go.



Hope this help, enjoy your 365 day 🙂


{Quick Tip} collapse or expand form sections without code

The trick is in form design mode the way we left sections, save and publish will be the state of form when they load. We can choose to collapse or expand all sections or go for a combination. I have not tested in previous versions but it works in 365 🙂

Enjoy your 365 day 🙂

#exand-or-collapse-crm-form, #how-to-expand-or-collapse-crm-form

Browser extensions for Dynamics CRM

Browser extensions are great software components which increase productivity and let browser do things which they can’t otherwise.

For Dynamics CRM a few add-ons are available which do fantastic things for CRM developers, testers and power users. This post will review these extensions and their features.


Dynamics CRM Power Pane



Dyanamics CRM Power Pane is developed by Onur Menal (CRM technical consultant from Turkey) and is available for Chrome and Firefox.

Its features are classified as:

  • Record Actions
  • Form Actions
  • Navigation.

For any record, with a click, we can see record guid, record url, entity name and entity type id. Copying a record to clone in a new tab is another useful record action. Form actions let the user enable all fields, show hidden fields, disable value requirement, get schema names as the field label, and copy schema names in form. Other features like showing optionset or field values, highlighting the dirty field and refreshing ribbon or form are also useful form actions. Navigation section directly opens a record, entity editor, and mobile clients. Power Pane also has some performance and diagnostic features.


Level up for Dynamics CRM/365 


Level up for Dynamics CRM/365 is developed by Natraj Yegnaraman (MVP from Melbourne, Australia) and is available for Chrome.

Its features are categorized as:

  • Forms
  • Navigation
  • Misc

Level up has almost all major features offered by Power Pane and a good thing is it offers some unique features as well. For example ‘God Mode’ makes all mandatory fields optional, hidden fields/tabs/sections visible and read-only fields editable. Some other cool features allow refreshing all sub grids, refreshing page and turning autosave off, toggling tabs, copying and pasting lookup value, opening lookup in a new window, seeing a list of business rules and workflows in a separate tab. From navigation section, in a new tab, it can open different CRM sections. Overall I have found it very useful.


Dynamics CRM DevTools 


DevTools is offered by Sonoma Partners (Microsoft Partner from the United States) and is available for Chrome.

It has some common features of other tools (like enabling form, showing schema names, showing hidden fields, refreshing form, record properties, performance tools, user and record details etc). Unique features are the possibility to run fetchXML, list of plugin, setting focus to a field and changing field value for testing. DevTools also offers a set of performance and debugging reports.


CRM Javascript Fiddle



CRM Javascript Fiddle is another tool developed by Onur Menal (developer of Dynamics CRM Power Pane) and is available for Chrome.

I have not got a chance to use it, here I m pasting its description provided by the publisher:

Run javascript codes on CRM without publish.
This extension allows you to run javascript code on Microsoft Dynamics CRM. In this way you can show hidden fields , you can enable and edit the disabled fields or you can achieve the available methods or object on web resouces of current form with “this” keyword. Such as


Also it provides storage support for your snippets.

Have you used or developed an extension which I have not covered in this post?  kindly comment if there is.

Please follow my blog to remain informed about upcoming posts.

Enjoy 🙂



How to find Business Rule, Form, View, Chart, Process and Message associated with a field

Sometimes we need to know which Form, View or Chart are using a field. Similarly we may need to check which Process and Plugin message are attached to a field. All these details can be viewed easily from field’s “Show Dependencies” functionality.

Generally navigation for “Show Dependencies” will be:
(Settings > Customizations > Customize the System > Components > Entites > Entity (Select your entity)  > Field (select your field) > Show Dependencies).

This window shows useful details about some other dependent components as well like Field, Entity Relationship, Email Template, Report etc. Business Rule is exception though, to see business rules we will need to click “Business Rules” button in same window.

Hope this tip will be helpful if you were not using it.

Please like/ follow my blog for more useful posts. Please feel free to leave a message, suggestion or question if I can help.

Enjoy 🙂


Upgrading To Dynamics 365 ?

At Sydney CRM Saturday Greg Olsen (Dynamics 365 MVP from New Zealand) presented “What You Need To Know To Upgrade To Dynamics 365”. It was a very nice and much valuable talk. Speaker not only shared his experience but also packs of chocolates and sweets 🙂


It has helped me understanding planning

phase of upgrade. Luckily Greg has shared presentation and I m sharing link in this post below:


Please like/ follow my blog if you found this post helpful. Feel free to leave a message, suggestion or question.

Have a very lovely weekend.

Cheers 🙂

How to view plugins deployment summary ?

Sometimes we need to know when last time a plugin was updated. This information is helpful usually before exporting assemblies from one environment to other.
In similar way few times we may need to know who updated a particular assembly last time ?

The following LINQ or Fetch Xml query will return this summary:

(from p in PluginAssemblySet
orderby p.ModifiedOn descending
select new
PluginName = p.Name, ModifiedOn = p.ModifiedOn.Value.ToLocalTime(),
ModifiedBy= p.ModifiedBy.Name, Role=p.ModifiedBy.LogicalName,Version=p.Version