Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Thursday, September 19, 2024

Power Platform Managed Identity support for Dataverse Plugins (preview)

This is a long overdue feature which allows Dataverse plug-ins to connect to Azure resources (e.g. Azure Key Vault) using managed identities, eliminating the need for credential management and enhancing security.   It currently is available in public preview but GA is expected for November 2024

You will need to create a managed identity record in Dataverse and link it ot your specific plugin assembly - for more details take a look at Set up managed identity for Power Platform (Preview) and Power Platform managed identity overview (Preview) for more details.

In your plugin, you will need to the implement the IManagedIdentityService interface which allows your plugins to interact with managed identities. Using this interface, your plugin can request an access token for a specific Azure resource. I asked Copilot to generate the code for this below but did not check it yet ...


In the meanwhile there is also a XrmToolBox plugin available to help with configuring the managed identity - see GitHub - drivardxrm/Driv.XTB.PluginIdentityManager: XrmToolBox Tool to help manage Managed Identity records in Dataverse

References:

Wednesday, October 28, 2020

Access token endpoint versions in Azure AD

You might have noticed that there are two different urls that you can use for retrieving an access token in Azure AD:

  • https://login.microsoftonline.com/<tenantid>/oauth2/token
  • https://login.microsoftonline.com/<tenantid>/oauth2/v2.0/token
And although most of the time it is better to use the more recent version, I did wanted to know the difference between both. After deciding that in this case google was not my friend I reached out a colleague @KevinDockx  (Definitely check out his Pluralsight training Microsoft Azure for .NET developers - Building secure services and applications )



Evolution of Microsoft identity platform explains how Azure AD developer platform evolved towards the new Microsoft identity platform. In short the /oauth/token endpoint is part of Azure AD for developers and /oauth2/v2.0/token is linked to Microsoft identity platform.



If you need to decide whether to use Microsoft identity platform (v 2.0) or Azure Active Directory (v1.0) endpoints - definitely take a look at Why update to Microsoft platform (v2.0) and check out the limitations section as well.

In short try to use the v2 as much as possible since it provides more features and is more in line with common standards. The v1 endpoints will still exist for quite a while and as far as I know there is no end of life announced (yet) but Microsoft did already announce the deprecation of the Azure Active Directory Authentication Library (ADAL) - see Migrate applications to Microsoft Authentication Library (MSAL). Everything evolves quite fast and there even is a newer alternative for MSAL called Microsoft Identity Web 

You might also take a look at OpenID Connect (OIDC) which is an authentication protocol built on OAuth 2.0 since Microsoft Identity platform is compliant with this standard as well - see Microsoft identity platform and OpenID Connect protocol for more details

References:

Wednesday, September 09, 2020

Fixing current .NET SDK does not support targeting .Net Core 2.2 in Visual Studio 2017

 I encountered below exception when building a ASP.NET Core project in Visual Studio - "The current .NET SDK does not support targeting .NET Core 2.2. Either target .NET Core 2.1 or use a version of the .NET SDK that supports .NET Core 2.2".


Luckily this forum post pointed in the correct direction - first check the installed version of the .NET Core SDK on your machine. 

If you are using Visual Studio 2017, you will need to install 2.2.1xx of the SDK to support targetting .NET Core 2.2. You can download the different versions of the .NET Core 2.2 SDK on https://dotnet.microsoft.com/download/dotnet-core/2.2 

Tuesday, September 01, 2020

Quick tip: workaround kernelspec module not installed with jupyter notebooks in Visual Studio Code

This weekend I tried out working with Jupyter Notebooks in Visual Studio Code. Since I already have Jupyter up and running as part of the Anaconda distro I thought this would be easy but it took me longer than expected. 

First step is to install the Python extension for VS Code  and then you can start working with existing Jupyter Notebooks by just double clicking an existing notebook. Unfortunately this immediately threw an exception "Error: Jupyter cannot be started. Error attempting to locate jupyter: 'Kernelspec' module not installed in the selected interpreter." The workaround suggested on StackOverflow Python/Jupyter notebook in VSCode does not use the right environment did not resolve the issue and also the fixes described on Github - New version tries to install kernelspec were not working.


The workaround which seems to be working for me is starting VS Code from the Anaconda Prompt in the Jupyter workspace directory by typing "code ."




Friday, August 21, 2020

Notes on learning to work with the Microsoft Graph API

Microsoft Graph is a REST API which allows you to access Microsoft Cloud services (e.g. Office 365 service like Microsoft Teams, OneDrive,Planner, SharePoint, etc.. but also enterprise mobility and security services like Azure AD, Identity Manager, etc..) resources using a single endpoint. You can use it for example for querying data in Outlook/Exchange and OneDrive but in the past couple of weeks I mainly used it for Microsoft Teams. The easiest way to get started with the Microsoft Graph API is the Microsoft Graph Explorer.


I learned quite a lot from the 30 days of Microsoft Graph blog series - a highly recommended starting point - for other resources take a look at the references section below.


References:

Friday, August 14, 2020

Don't forget to update older client applications for Dynamics 365 to the correct .NET Framework version

I lost 30 minutes this morning when trying to troubleshoot an older console app (written in 2017) which refused to connect to Dynamics 365 Customer Engagement. It was only after updating the Nuget packages for Microsoft.CrmSdk.CoreAssemblies  that I noticed that I was still building against .NET Framework 4.5.2 which is not supported anymore.


Reference:


Tuesday, April 28, 2020

What can you do with the Azure Cosmos DB free tier?

Beginning of March 2020, Microsoft announced the availability of a free tier of Azure Cosmos DB (see Azure Cosmos DB Free Tier is now available)

"When free tier is enabled on an Azure Cosmos DB account, you’ll get the first 400 RU/s and 5 GB of storage for free for the lifetime of the account. Additionally, when using shared throughput databases, you can create up to 25 containers that share 400 RU/s at the database level. There’s a maximum of one free tier account per Azure subscription and you must opt-in when creating the account."

But maybe you are wondering what you can actually do with 400 RU/s? Request Units per second (RU/s) represent the "cost" of a request in terms of CPU, memory and IO. In Azure Cosmos DB you can provision "performance" upfront by setting RU/s at database level, collection level or both. It is however also possible to create Azure Cosmos DB containers and databases in autoscale mode  Containers and databases configured in auto scale mode will automatically and instantly scale the provisioned throughput based on your application needs without impacting the availability, latency, throughput, or performance of the workload globally

I can highly recommend you to take a look at the Microsoft Ignite 2019 session - A developer's guide to Azure Cosmos DB, from onboarding to going live in production . The code samples from session are available on Github - https://github.com/deborahc/cosmos-perf-tips

References:

Tuesday, March 10, 2020

Enabling C# 7.1 in Visual Studio 2017 projects

Today, when I tried to compile one of the Visual Studio projects in our solution - I received the exception "Feature 'default literal' is not available in C# 7.0. Please use language version 7.1 or greater". (For more info see default literal in C# 7.0)



To enable C# 7.1 you need to following these steps:

  • Right click on your project and select Properties, next navigate to the build tab and click Advanced

  • Next you can either choose C#7.1 from the list or choose C# latest minor version (latest).

Thursday, February 06, 2020

Quick tip: keep your Dynamics 365 development tools up to date using Nuget

I recently encountered an issue when I tried switching the view of the registered plugins & custom workflow activities in the Plugin Registration Tool.



When updating to the latest version using the PowerShell script listed on Download Dynamics 365 development tools from Nuget the error got resolved. Lessons learned: make sure that you keep your Dynamics 365 development tools up to date.

Thursday, August 01, 2019

Code tip: Nullable datetime in C#

Nullable types are used when you need to represent the value of an underlying type. By default DateTime is not nullable in C# because it is a Value type, but using the Nullable construct (or the ? shorthand), you can assign the null literal to the DateTime type. Syntax is below:

 DateTime? dt = null;  
 Nullable<DateTime> dt = null;  

Wednesday, June 05, 2019

PowerApps Component Framework available in public preview

On April 23th the PowerApps Component Framework (PCF) and the PowerApps CLI was finally made available for public preview. The PowerApps Component Framework (PCF) is the foundation for all controls used in the new Unified Interface released with Dynamics 365.



PCF allows 3d party developers to build visual components using the same framework which is used internally by Microsoft (see picture below for some examples) in the unified interface.


Components created using the PowerApps Control Framework are solution aware and can be used to build a more compelling user experience. The Dynamics365 developer community immediately picked up on this exciting news and Andrew Ly already shared the source code for 3 different controls  - Progressbar control , keybinding example  and countdowntimer.

Guido Preite  @crmanswers also set up PCF Gallery which contains a list of different controls like a timeline control, data card and UK postcode validator. Everyday new controls based on PCF are added.



The PowerApps Component Framework has been in private preview for quite a while but some details were already shared on a number of occasions in 2018. Initially the framework was called Custom Controls Framework and I you encourage to take a look at some interesting post from Bob Guidinger on this topic (see references below). Do keep in mind that there are some changes between the private preview and public preview – see Update existing custom components for more details.

You will notice from the documentation that most samples are using Typescript to implement custom components so I added also some other reference links below which might help you to get started. For a brief introduction you might also want to take a look at the PowerApps April community call recording (PCF presented from 00:47:00 onwards). One thing to note though is that this is a framework which is clearly targeted at professional developers so the Dynamics consultant who occasionally writes some Javascript web resources or some simple plugins in C# will face a steep learning curve. I even think that pure Javascript/.NET developers even have an edge on the average Dynamics consultant when trying to learn the necessary skills required for PCF development.

References:

Thursday, September 13, 2018

Quick tip: CRMServiceClient vs CRMConnection

Starting with Dynamics 365 build number 9.*  you must use the XRM Tooling assemblies and the CRMServiceClient instead of the CRMConnection class – see https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/choose-development-style for more information.
First you will need add the nuget package Microsoft.CrmSdk.XrmTooling.CoreAssembly (Core assembly required to develop managed code using the Xrm Tooling Connector)

Afterwards, there are a number of ways that you can instantiate a CRMServiceClient object – see  Use CrmServiceClient constructor to connect to Dynamics 365 or Use connection strings in XRM tooling to connect to Dynamics 365

Sunday, January 07, 2018

Fix for unable to login to Dynamics CRM 9.0 with CrmServiceClient and .NET 4.7

When you try to connect to Dynamics 365 9.0 from within a console app using the CrmServiceClient, you might still encounter an error “Unable to login to Dynamics CRM” even though you have updated to the latest version of the different assemblies (9.0.0.7 at the moment of writing).

This might be caused by the fact that you compiling against .NET 4.7 where the default value of the ServicePointManager.SecurityProtocol is SecurityProtocolType.SystemDefault (See What’s new in .NET 4.7 for more details).

If this is the fact, you might need to explicitly change the protocol to TL1.2 - which is a requirement for Dynamics 365 9.0 as announced in September 2017 in Updates coming to Dynamics 365 Customer Engagement connection security  - by adding a line ServicePointManager.SecurityProtocol.SecurityProtocol = SecurityProtocolType.Tls12