HTTP Trigger Azure Function Authorization Types simplified

Now, many of you must be wondering how the Authorization types for Azure Functions using HTTP Triggers work and where to look for information while using these different types. Hopefully, this post helps simplify each of those for you.

Now, when you create a new Azure Function from Visual Studio or from the Azure Portal, you’ll be asked about Authorization where you’ll find the selection to either be 1 of the below –

  1. Anonymous
  2. Function
  3. Admin
  4. System

Anonymous

This type of Authotization let’s you use the Azure Function without needing for any key and anyone with the URL alone can access it. Of course, this is not recommended for any production use –

  1. Now, if you notice your Visual Studio, when you write your first Azure Function, it comes with pre-defined method ready for you to continue to write your own code. But right away, you’ll see that the Authorization method is pre-defined considering you must’ve selected Anonymous while starting the Project.

  2. Also, since the Azure Function is understood to be Published already on the Azure Portal, you’ll see in the Function’s settings that the same has been reflected as well.

  3. Now, if you test this using Postman, the code will be able to run directly just using the URL without any API key. Either you pass in the body – and you’ll get a 200 OK with the result that the Azure Function is supposed to result.


    Or using query parameters – the result will be the same.


    This simply explains Anonymous authorization. Without any check on who’s supposed to access the Azure Function.

Function

In this type of Authentication, only the Function and resources associated to it will be accessible. This needs the caller to have a key [or code] to be passed while calling Azure Function –

  1. Let’s look at the code, and see that the type is not set to Function for Authorization.

  2. And when you Publish the code, the same will be reflected in the Settings too.


  3. And when you want to access the Azure Function from Postman, you’ll need the Function Keys defined in the Function Keys area of the Function itself – a Default Key is given already but you can choose to add your own keys and using any of them would do.

  4. Now, here’s what the Key looks like when you click on Show [there’s a button on the far right to expose the key’s value]

  5. Now, when you go to Postman, you need to can pass this as a query parameter –


    Now, let’s look at the Admin Type of Authorization.

Admin

In this type of Authorization, you get access to Functions’ Runtime APIs. The way to use the Admin key is similar to the Function Keys, just that they are available from the Function App itself than the Function –

  1. Now, when the Authorization is set to Admin

  2. You’ll see this reflected in the portal once Published.

  3. Now, in the Function App itself – you can navigate to the App keys under Functions [as of the portal’s layout in mid-2024]

  4. You can expose to see this value and share it to the clients who are going to consume this Function App. They key required here is the _master

  5. Now, you can test this using Postman


    Remember, this type of Authorization is to be used when the calling client needs to also access Functions Runtime API.
    Finally, Let’s look at the System type.

System

This type of key is managed by Function runtime and is used when the calling client when there’s a need for granular access to function runtime features.

  1. Now, you can set this from the code and publish it.


  2. And it’ll appear in the settings of the Function [In case when the Function wants to access granular function runtime features].

  3. And this is present in the App keys area under System Keys section.

  4. And when you test the same, they work just like any other key from the Function app when called.

Hope this was useful!

Create your first custom Copilot for Customer Service Hub – Part 2 | Authentication

Now, you must have created your own Copilot to be deployed for the Customer Service Hub. If not, here’s the link to Part 1 of this blog – Create your first custom Copilot for Customer Service Hub – Part 1

Configure User Authentication with Microsoft Entra ID

Here’s how you can configure the User Authentication with Microsoft’s Entra ID for your Copilot to be authenticated with –

  1. Go to the Azure Portal [https://portal.azure.com/], then given the appropriate permissions your might have, you should be able to create an App Registration

  2. Now, create on New Registration –

  3. Now, give it a suitable name so that you can identify that the purpose of this App Registration is for Copilot. Select multi-tenant, leave Redirect URI blank and click on Register.

  4. Once ready, go to Authentication and then click to add Platform.


  5. In the platform selection, click on Web.

  6. Now, enter the URIs – First, enter the first URI, make sure to select Access tokens and ID tokens in Implicit grant and hybrid flows section and then click Configure.

    https://token.botframework.com/.auth/web/redirect
    https://europe.token.botframework.com/.auth/web/redirect



  7. Then, go ahead and add the Second URI from the main screen itself. Then, click Save and refresh the page once.

  8. Now that both the URIs are added, click on the configuration link to consider both the links for configuration.

  9. Now, you’ll be taken to this pane where you can click

  10. Now, both the URIs will appear here.

  11. Next, generate Client ID and Client Secret as you’ll need these details too –


Set Copilot Authentication to use Custom Authentication

Going back to the Copilot itself, set the Authentication you just created in the Azure Portal –

  1. Go to Settings on the Copilot to use the Custom Authentication.

  2. Go to Security section and then select Authentication.

  3. Select Authenticate manually and then enter the details as shown below. Enter the Client ID and Secret which you must’ve saved before.



  4. Next, come back to Copilot Settings and in Security, go to Settings and then look for Web channel security.

  5. Once you open it, you’ll find that the Secured Access is disabled. Go ahead and enable it.
    It takes up to 2 hours for it to take effect. Till then, old settings apply.

  6. Finally, in Channels, select Customer Service Hub so that you can connect to the Customer Service Hub.

  7. On the right hand side pane which opens up, you’ll see that this is not connected. Click the Connect button.


  8. It connects to Customer Service Omnichannel in a few moments.


Part 1: Create your first custom Copilot for Customer Service Hub – Part 1

Hope this was useful!

Thank you!

Create your first custom Copilot for Customer Service Hub – Part 1 | Create Copilot

Now, if you already have Copilot Studio in your Organization or have created a trail [Start your Copilot Studio Trial], you might be looking to build your first Copilot. Here’s how you can do it –

In this example, I’m creating a Copilot to help new Customer Service Reps at the organization to search and seek help about the organization itself quicker.

Create your Copilot

Here’s how you can start building your first custom Copilot –

  1. In your Copilot Studio environment, you must be seeing this New Copilot button in Copilot section. Click that.

  2. Here’s you need to start describing the Copilot you are looking to create. This is optional but recommended to do so as first step. It’ll ask you some questions on the context of the Copilot which you are looking to create.

  3. After it gathers some information from you, it’ll summarize what the Copilot is aimed to do.
    Now, once done you can click Skip to Configure to go to the next step.

  4. Further, you can name the Copilot and then start adding Knowledge by adding sources where the Copilot will source information from.

  5. Some of the most common ways for the Copilot to source knowledge from is from website and SharePoint data itself.

  6. In this example, I’m sourcing some information about whitepapers from thecompany’s website itself.

  7. Now, once this is ready, I’ll further proceed to Create the Copilot itself once relevant Knowledge links have been added as required. Once done, click Create.

  8. Now, once the Copilot is created – it’s ready to be configured further or even ready to be Published if nothing else is to be added at this point.
    You can scroll down in the details section and find that the Copilot is ready to be Published.
    Note that based on the Copilot settings for Channel, it’s only available to Teams at first – but you need to configure for other channels – like Customer Service Hub [in this case]


  9. Now that this is published. –

  10. Your Copilot is now ready!

In the next blog, we’ll connect this Custom Copilot to Customer Service Hub – Create your first custom Copilot for Customer Service Hub – Part 1 | Create Copilot

Hope this was useful!

Thank you!

Start your Copilot Studio Trial

Here’s how you can try out Copilot Studio for free first. Along with that, here’s the Copilot Studio Pricing – https://www.microsoft.com/en-us/microsoft-copilot/microsoft-copilot-studio#Pricing

Copilot Studio Trial

Here’s how you can start your own Copilot Studio Trial.

  1. Navigate to the Copilot Studio homepage – https://www.microsoft.com/en-us/microsoft-copilot/microsoft-copilot-studio
    You’ll see this Homepage and you can see a button to Try free

  2. Then, just like any other Sign up process for Microsoft products, you can start by the entering the Email of the org which you want to provision this on.

  3. Once you click Next, you’ll be asked to Sign In once everything looks good to be provisioned.

  4. Once you Sign In, you’ll be asked for Region and Phone.

  5. Once you click on Get Started, you’ll be asked for final confirmation and then it’ll start provisioning.

  6. Once you click on Get Started, it’ll take a few minutes to get provisioned.
    Then, you’ll finally see Copilot Studio show up. Select your region and Get Started.

  7. Finally, switch to the right environment which you wish to work on.
    It’ll start with a Welcome Wizard and you are ready to go and start your Copilot Journey!


    And this is where you can start exploring within the Copilot Studio!

Hope this was useful!

Thank you!

Lock fields on Editable Grid using JavaScript in Dynamics 365 CRM

At times, you use Editable Grid and by default – all the fields which are editable by the system are exposed and can be edited if they are present on the Editable Sub-grid. You might not want to allow all fields to be editable on the Editable Grid – so here’s how you can lock selected fields on the Editable Grid using JavaScript.

Use Case

Let’s look at the below example where by default, the fields are Editable because you are using an Editable Grid –

  1. You might want to lock the Status field since it shouldn’t be something end user should be able to change by themselves.


  2. So in such scenarios, you might want to keep most fields open but lock some of them on the Editable Grid itself. Let’s see how we can do it using JavaScript

JavaScript Code

Here’s a sample code which you can use to loop through all the fields you want to lock on the Editable Grid –

  1. Code within a class – [You can just use the lockFields function separately too.]

    oSubscriptionCustomization = {

    lockFields: function (executionContext) {
    var oFormContext = executionContext.getFormContext();
    if (oFormContext) {
    var arrFields = ["cft301_status"];
    var objEntity = oFormContext.data.entity;
    objEntity.attributes.forEach(function (attribute, i) {
    if (arrFields.indexOf(attribute.getName()) > -1) {
    let attributeToDisable = attribute.controls.get(0);
    attributeToDisable.setDisabled(true);
    }
    })
    }
    }
    };

  2. In the above code, I’m reading from an array called arrFields and all the fields listed in the array will be looped through and locked.
  3. Once my JS file is ready, I can open the Editable Grid control itself on the parent form and then loop for Events tab to register my function on the grid.

  4. In the Event tab, look for the UI Event called as OnRecordSelect

  5. Here, you can register your function. Since, I’m using class too – I’ll use classname.functionName

  6. Once done, save and publish your changes. Now, you’ll see that the field is locked when you select the record on the Editable Grid.

Hope this was useful!

Thank you!

Update SVG Icon to Custom Entity in Sitemap | Model Driven Apps

So, if you are used to updating Icons to entities in the classic UI, here’s what you need to do in order to update the SVG image of a Custom Entity you just created using new Power Apps Maker portal.

Let’s see below is you custom entity and it comes with its default icon which you want to set to a custom SVG icon.

Adding SVG Icon to Custom Entity

Given that you have appropriate access to the be able to Customize the system, follow the below steps –

  1. In your solution, you have the table as well as the SVG Icon you just created the Web Resource for and uploaded an image which you want to set as Icon.

  2. Now, select the Table you want to set the SVG icon to, and click on Properties.

  3. On the right hand pane, expand the Advanced area and look for the Choose table image field.


  4. Then, start typing the Display Name of the SVG icon which you wish to set to this Entity.


    Click Save if no other changes are to be done.

  5. Once Saved, click on Publish.

  6. Now, when you refresh the App where the custom entity is listed in the Sitemap, you’ll see the icon updated.

Hope this was useful!

Thank you!

Preferred Solution in Dataverse | Power Platform Admin Center

By default, everything goes inside a Default Solution if you are aware of the classic way of doing Customization in Dynamics 365 CRM. And this causes components to be lost in Default solution without knowing who created where and what was that.

Hence, to be able to collect all the components created outside of Solutions, Preferred Solution is a great way to automatically add components created outside Solution in a single solution to ensure accountability.

Let’s see how this works with help of this simple post!

Mark a Preferred Solution

Given you have appropriate rights like System Administrator or System Customizer, you can go to the Maker Portal (https://make.powerapps.com/), and follow the steps below –

  1. In the Power Apps Maker Portal, when you navigate to Solutions – you’ll see a message saying ‘Set your preferred solution’ and on the right hand-side show that the Common Data Services Default Solution is already preferred [You’ll know this from Customizations option in classic UI].

    And on the top, you’ll see button to Set preferred solution.


  2. Now, when you select to set preferred solution, you’ll see all the unmanaged solutions you have.
    Select the one you want to mark as Preferred for anything not directly added to a solution.

  3. Then, you’ll see that Preferred Solution label has been applied for that Solution.

  4. Now, even if you add anything directly from other areas like Tables and add a field (for example), it’ll end up having the Prefix of the Solution itself.


  5. In this example, it’s add Field 2. The Prefix set for the Preferred Solution was “cf301

  6. And when you open the Preferred Solution itself, the component you created outside the solution will be added to the Preferred Solution automatically.


  7. This way, it’s easy to not lose any customization in Default Solution and makes it easy for all the components which were created outside of the solution to be gathered in place when you want to investigate your environment!

Hope this was useful!

Thank you!

Button to send Email based on Templates in Dynamics 365 CE

Great blog below by Vidit to demonstrate how you can use ribbon buttons in Dynamics 365 Sales to send emails based on Templates.

Use Monitor to debug Model-driven apps remotely | Power Platform

Monitor is one feature that comes in super handy when end-users complain about an issue which is difficult to ask end users to send across logs from the browser.

And here’s where Monitor comes in handy!
Let’s see how this works through this simple blog post!!

Capture events from Monitor in Model Driven Apps

Here’s how you can Monitor in Model-driven apps’ Monitor to capture issues on an End User

  1. You can go to Power Apps Maker Portal (https://make.powerapps.com/) and make sure you are switched to the intended environment.
  2. Then, select Apps on the left hand pane and expose all the Apps. Select the Model-Driven app you want to enable Monitor for. Once you select, you can then drop down from Details flyout menu and click on Monitor.

  3. Once you click on Monitor, it opens the Monitor application itself where all the logs you work on will be captured. And you can also notice that there’s a Play model-driven app button as well to enter in Debug mode.


  4. It opens the Model-driven app in a new tab and asks you to confirm if you want to join the debug session.

  5. Once you click on Join, it’ll run the app in debug mode and you can see the Monitor tab and notice that it has started capturing the logs based on your operations in the Model-driven app session you are running in parallel.


  6. And when you go about working in the model-driven app, it’ll keep capturing the traffic just like on a browser’s Network in Dev Tools

  7. Now I deliberately added an erroneous code in my custom JS so that I could capture an exception in the monitor.

  8. And if you look at the monitor, you’ll see that this has been captured.

  9. And this is the wrong script I entered so that my code wouldn’t find the incorrect field name and throw an error when I try to retrieve value from an attribute that doesn’t exist (without null checking if the attribute exists or not)

  10. However, best use case is when you ask end-users to join your session. Let’s see in the next session on how you can achieve this.

Invite Users to your Debug session

In the Model-driven apps monitor, here’s how you can invite other users to join your session –

  1. In the Monitor, you’ll see Invite or Connect to a User. For this example, I’ll choose Connect user option.

  2. Then, I can simply search for the User whom I want to generate a join link for.

  3. Now, once this user is added, you’ll see a copy link option to copy the link and pass it on to the user who needs to join.

  4. Once the end user has this link, then can join the session and they’ll see this message on their Dynamics model-driven app

  5. And similarly, once they start reproducing the issue, you can start capturing the traffic on your end.


Hope this was useful! In order to fully understand the capabilities of Monitor for model-driven apps, here’s Microsoft’s official documentation – https://learn.microsoft.com/en-us/power-apps/maker/monitor-collaborative-debugging?WT.mc_id=DX-MVP-5003911

Hope this was useful!

Thank you!

Why Environment Variables don’t appear in Flows? | [Quick Tip]

At times, if you are new to working with Environment Variables and you’re looking to use them in your Flows but don’t see them?

Here’s why!

Flows Outside Solutions

If you are creating Flows from the My Flows section, let’s see if you can access Environment Variables or not –

  1. If you use My Flows way to create your Flows as shown below –

  2. You won’t be able to access Environment Variables in that Flow

Flows in Solutions [Default and other Solutions]

So, you’ll need to have your Flows inside a Solution – even if you are creating a Flow in Default Solution, you’ll be able to access Environment Variables from another solution –

  1. If you are in a Default Solution as shown below and you create a Flow there, you’ll be able to access Environment Variables.


  2. And you create a Flow there, you’ll be able to access Environment Variables.

Hope this was useful!

Thank you!