Friday, September 28, 2018

How to setup Azure Key Vault with Dynamics 365 for Finance and Operations

Azure Key Vault is a service that allows you to store secret keys, like passwords or certificates for external web-services, to be used by your different apps. When stored in Key Vault, none of your apps need to know details about or store these secrets by themselves. No more passwords laying around in code, in your version control system, in configuration files etc.

You can read more about Key Vault here.

Dynamics 365 for Finance and Operations has integration with key vault. It's just not very well documented and for now it seems only used a few places for integrations with different authorities.

I can't find any documentation on docs about the setup of Key Vault with Dynamics 365 for Finance and Operations, but I was able to find this support guide in stead:

If you follow the guide you'll be able to do the necessary setup on Azure.

In Dynamics you can find the setup form under System administration / Setup / Key vault parameters:

Let's try to figure out how to add a configuration to this form.

I have created a key vault called "PallesVault":

The "DNS Name" from the vault is what you enter in the "Key Vault URL" field.

I have registered my Dynamics instance as an app, as described in the support article. And I have added a Key to the registration. The Application Id and the secret key I have added goes into the "Key vault client" and "Key vault secret key" fields.

I have added single secret to my vault, which is my phone number ("Telefonnummer" is danish for phone number):

The address of the secret goes into the "Secret" field, as "vault://pallesvault/PallesTelefonnummer"

So, to get the value of this key from Dynamics the setup looks like this:

And here is some quick and dirty test code:

public static void main(Args _args) 

    KeyVaultCertificateTable keyVaultCertificateTable; 

    select firstonly KeyVaultCertificateTable 
        where KeyVaultCertificateTable.Name == "Telefon"; 

    str secretValue = KeyVaultCertificateHelper::getManualSecretValue(KeyVaultCertificateTable.RecId); 

    info (secretValue); 

In regards to pricing for the key vault, there is a Standard and a Premium tier. Standard is nearly free and Premium will set you back around 1$ a month.

Go secure your secret keys.

Friday, September 14, 2018

Timing in PowerApps

Just for fun I tried to build a PowerApp, to be embedded in D365 FinOps, that would show some PDFs for at particular item.

I keep the PDFs in a SharePoint document library and use ItemId as a key.

And resulting the app looks like this:

Of course I need to filter the SharePoint list to only show entries related to the current item, and I added the following to OnStart of the app, like described on docs:

If(!IsBlank(Param("EntityId")), Set(FinOpsInput, Param("EntityId")), Set(FinOpsInput,""));

And here is what I have put in Items of the Gallery showing the SharePoint data:


A problem I have spent hours on, was that the filtering was very flaky. Sometimes it would flicker, showing all my items and then apply the filter, and sometimes it just didn't apply the filter until I manually refreshed the list.

It seems like things run i parallel when you open an app, so it would actually start to load data from SharePoint before or while the OnStart trigger is executed. And in some cases it wouldn't know about the FinOpsInput variable yet when applying my filter.

A solution could be to add a variable to OnStart, letting you know if that is finished, and make a bogus filter until it is done. Like this:

If(!IsBlank(Param("EntityId")),Set(FinOpsInput,Param("EntityId")),Set(FinOpsInput,""));Refresh(ProductPDFs);Set(AppIsStarted, true)

And change Items of the gallery to this:
If (AppIsStarted, If(!IsBlank(FinOpsInput),SortByColumns(Filter(ProductPDFs,ItemId=FinOpsInput),"ItemId",Ascending),SortByColumns(ProductPDFs,"ItemId",Ascending)), Filter(ProductPDFs,ItemId="BOGUS"))

This video explains what you need to know to build the app

Monday, September 10, 2018

A collection of links releated to Dynamics 365 FinOps and PowerApps

A collection of links releated to Dynamics 365 FinOps and PowerApps. Please comments if I have left put something important.

Embed PowerApps apps
How to embed PowerApps in Dynamics 365 for Finance and Operations Video
Getting started with canvas apps
Sample app for looking up exchange rates
Sample app for generating product labels
PowerApps Host control
PowerApps dashboard
PowerApps Documentation
Environment and tenant app migration through Packaging
Free PowerApps Plan 2 trial
PowerApps Community Plan Signup
PowerApps Community Plan Details
Environments overview
PowerApps community
Microsoft Flow community

Wednesday, September 5, 2018

Comparison of Azure prices

It just needed to do a new deployment though my Visual Studio Azure subscription, and as usual I couldn't remember the price variance between regions and types of machines.

I stumbled over this site which gives a good overview: 

I don't know how accurate they are, but I was able to see variances and that was what I was looking for.