Friday, 8 September 2017

Azure AD Authentication for Windows Applications

In this post I will describe how you can get the login dialog to pop up when you are developing a windows desktop application.

Below is an example of the dialog appearing.

image

Below is a sample code how to acquire the token.

string authorityUri = "https://login.windows.net/common/oauth2/authorize";
Uri redirectURI = new Uri("https://login.live.com/oauth20_desktop.srf");                

AuthenticationContext authenticationContext = new AuthenticationContext(authorityUri);

AuthenticationResult authenticationResult = authenticationContext.AcquireTokenAsync(
   ClientConfig.Default.ActiveDirectoryResource, 
   ClientConfig.Default.ActiveDirectoryClientAppId, 
   redirectURI, 
   new PlatformParameters(PromptBehavior.RefreshSession)).Result;

Add the redirect URI for https://login.live.com/oauth20_desktop.srf

image


Reference: https://docs.microsoft.com/en-us/rest/api/datacatalog/authenticate-a-client-app

Thursday, 31 August 2017

Table casting in AX 2012 and D365O

D365O is a lot more sensitive about casting or should I say AX2012 was too relaxed about it. This post is to show a specific scenario that works differently in the new version of the product.

We had a bit of code that worked fine in AX2012 but stopped working in D365O. After debugging we found that when you cast a table it took the tableId of the cast.

Below is an example of AX2012 vs D365O:

image

image

UPDATE – Thanks for Joris for pointing this out.

Same code running in CIL in AX2012. The piece of code in question was running client side. Otherwise, I would have noticed this in AX2012 too.

image

Wednesday, 23 August 2017

Daxeam Mobile Solution Released on Apple App Store and Google Play Store

I am very happy to say Daxeam Mobile is now available on Apple App store and Google Play Store. Daxeam Mobile fully working on both Dynamics 2012 and Dynamics 365 for Finance and Operations, Enterprise Edition.

imageimage

Daxeam is an Enterprise Asset Management (EAM) solution available exclusively for Microsoft Dynamics AX 2012 and Dynamics 365 for Finance and Operations, Enterprise Edition. The Daxeam solution extends the functionality of AX, delivering integration to EAM across Projects, Inventory, Finance and Fixed Assets.

Some key items to note about the Mobile solution:

  • Daxeam Mobile is an application built from the ground up to work with the Daxeam
  • Login is managed security via Azure Active Directory
  • Works for both AX2012 and D365O
  • Offline capable – has sophisticated sync capabilities to download your data locally and syncs back up when connection is available
  • Features available
    • Asset hierarchy
    • Asset management such as meter updates, view attributes, structures and related history
    • Work order management such as creating, editing, status updates, registering hours, registering items, executing your checks and many more
    • Observation management such as creating, editing
    • Taking pictures
    • Searching and Barcode scanning

image

Saturday, 15 July 2017

Hybrid connection - Web Api App for AX 2012 to Azure-part 4

This is the final post of this series.

Web Api App for AX 2012 to Azure–Intro
Deploy a Web Api App for AX 2012 to Azure–part 1
Application settings - Web Api App for AX 2012 to Azure-part 2
Authentication - Web Api App for AX 2012 to Azure-part 3
Hybrid connection - Web Api App for AX 2012 to Azure-part 4 (this one)


In this post we will set up a Hybrid Connection. This is basically a listener that sits on your on-premise server. It will expose internal port to Azure. More information on Hybrid connection on Microsoft’s site.

https://docs.microsoft.com/en-us/azure/biztalk-services/integration-hybrid-connection-overview

In your Api App, click on Networking. Then click on “Configure your hybrid connection endpoints”.

image

First download the connection manager. Install this on your on-premise server that you want to install the listener.

You don’t have to run the connection manager just yet. Set up the hybrid connection by clicking on the “Add hybrid connection”

image

Click on the “Create new hybrid connection”

image

Enter the required detail. Host is the AOS server name. The port is the net tcp port number.

image

If unsure what port to enter. Have a look at the net.tcp address in the wsdl or inside the web config file.

SNAGHTML1be4f1aa


Now lets run the Hybrid connection Manager you installed a few steps earlier. Click on “Configure another Hybrid Connection”. It will ask you to log in. Once logged in, you can seelect an existing connection. This is what you created in the portal. Click on Save and you should see a green “Connected” status next to it. The web portal should show the same.

image

That is it. Give it a test by navigating to the swagger URL. The URL is just the Api App url suffixed with swagger. eg.

https://axaptaapi1.azurewebsites.net/swagger

Authentication - Web Api App for AX 2012 to Azure-part 3

Lets set up the authentication in this post. You should always secure your application and never leave it exposed out to the web.

Click on Authentication menu and turn it on. In the drop down, select Azure Active Directory. In the Authentication providers click on Azure Active Directory to start configuring it.

image

Select the Express mode. This will create an web App registration.

image

Once authentication is configured. Lets set up a native Application registration. This step is only required if you are trying to communicate to the web service via a desktop applications, mobile application, third party tools to access your web services.

More information on application permissions and authentication on the Microsoft article.

https://docs.microsoft.com/en-au/azure/active-directory/develop/active-directory-authentication-scenarios

Navigate the the Active directory menu and click on Application permissions. You will see the “Web app/API” application registration. We will create a Native application registration.

image

When creating it you will be asked to enter a redirect URI. Enter a valid uri.

image

Click on the Native application registration and click on Required permissions. Add the Web App registration and Grant permissions (button at the top).

image

When you are adding it. You will have to search for it. It wont show up on the list automatically.

image

We are done.


Now lets test it by navigating to the swagger url. You will be asked to log in and also accept permissions.

image

There is a test service you can run to check that it has recognised you.

image

Application settings - Web Api App for AX 2012 to Azure-part 2

Last post showed how to publish your solution to Azure. This post will show you where to modify the the application settings. In visual studio you would be modifying the web config file. In the cloud you will modify the Application settings.

image

Find your Api App. Click on Application settings. Scroll down to App settings.

image

Deploy a Web Api App for AX 2012 to Azure–part 1

Continuation from previous post. In this post I will show how  publish your solution to Azure.

I assume you have followed the instruction from the GitHub wiki to download and configure.

https://github.com/ffilardi/AxaptaAPI/wiki

Now that you have done that. Lets deploy.

Create a new Api App. You might have to search for it if its not available on the menu.

image

Give it a name and select a Resource Group. Obviously pick a data centre location that is close to your AOS. If I am not sure, I like to use this site to find the closest with the lowest latency.

http://www.azurespeed.com/

image

Now you have an empty Api App. Grab the Publish file by clicking the “Get publish profiles”. This is not necessary but if you have other developers who don’t have access but you want them to publish. This one of the ways.

image

In Visual Studio right click on your project and click Publish.

image

Follow the wizard. You can sign in and select the Azure resource to deploy it to. Otherwise, use the publish file to import and publish (doesn’t require you to sign in).

image

Once its deployed. Just navigate to the swagger URL. Should look like this

https://myapiapp.azurewebsites.net/swagger

image