web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Do i need to have an azure account to use Dynamics CRM Web API ?

(0) ShareShare
ReportReport
Posted on by 25

Hello,

I have to expose some data from my CRM using the CRM Web API. So i read somewhere that i  need to have a Azure account to use this web API. Is that true ? I'm not sure if i correctly understood that. 

If yes, do you have some docs or something like that to help me to create this account and get client ID i can use in my project. 

Thanks to read me, Peace.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Prashant_ Profile Picture
    1,040 on at

    You required azure for 2 reasons

    1.Hosting of your web API 

    2.user  Azure Active Directory (ADAL) for identity and access management.

    You can get cheaper hosting plans on other web sites or you can host your service on your  IIS so for first is optional for you as per your costing.

    Now ADAL is required for your service but  if you are using hard coded credentials in your service (not good solution) then you don't need azure.If you want to connect crm using web api and expose data then you need to use ADAL for secure  connection as well as good solution design then you need azure.You can get special subscription for azure AD in admin portal of office 365.You need azure for identity management.

  • Verified answer
    Kokulan Profile Picture
    18,054 on at

    To Access CRM Data from an external system, you will need the following setup

    01. You will have to Register An App with Azure AD  - App Registration

    https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/mt622431%28v%3dcrm.8%29 

    02. You will then have to add the registered App in CRM as an Application User and set the security roles for this Application user account - Application User Setup In CRM

     

    03. To access CRM from External Systems using OAuth, you will have to use ADAL (Microsoft Azure Active Directory Authentication Library). This library is available for many different languages including Javascript and C# - Authenticating and Getting Access Token

    For JS : 

    https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/mt595797(v=crm.8)

    https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/mt595799%28v%3dcrm.8%29

    For C# : 

    https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg327838%28v%3dcrm.8%29 

    04. Add the token obtained in Step3 to request header as bearer token and access data from CRM - Access CRM Data using OAuth Token

    To answer your main question of do you need to create an Azure account, No you already have one. When you have a CRM Online instance, you are accessing it via Office 365 which in turn uses Azure AD to authenticate you and allow you to access CRM. You do not need to create a separate Azure account to register an App to authenticate to CRM via Web Api endpoint.

    Please go to your Office 365 Admin Center and Click on All Admin Centers and you will see Azure Active Directory as shown below

    5355.ScreenClip-_5B00_329_5D00_.png

    Clicking on the Azure Active Directory link will take you to Azure Portal where you can register an App to authenticate to CRM via Web Api endpoint

    5355.ScreenClip-_5B00_329_5D00_.png

    Please follow the links below for full details on how to register the app in AAD.

    www.youtube.com/watch

    https://community.dynamics.com/crm/b/d365crmcatalyst/archive/2018/03/05/setting-up-azure-active-directory-authentication-on-azure-web-api

    More links on oAuth to CRM

    https://community.dynamics.com/crm/b/zsoltzombiksblog/archive/2016/01/05/how-to-authenticate-to-microsoft-dynamics-crm-with-the-web-api

    https://blogs.msdn.microsoft.com/crm/2013/12/12/use-oauth-to-authenticate-with-the-crm-service/ 

    If you are new to CRM Web Api, please follow the link below to know more about it

    https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/mt593051%28v%3dcrm.8%29

    Note: If your external system is a .NET application or web site, you can also use Dynamics CRM SDK to access CRM and if you go with this approach, you do not need to use OAuth, you can directly use an account login to authenticate and access data.

    https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg328497%28v%3dcrm.8%29 

    https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/mt608074%28v%3dcrm.8%29

    ADAL Library for different languages and platforms :

    https://docs.microsoft.com/en-gb/azure/active-directory/develop/active-directory-authentication-libraries

  • Shirro Profile Picture
    25 on at

    You guys are monsters ! Thank you to take time to answer me ! 

    I think i have everything i need to do what i have to do. 

    Have a nice week-end !

  • Shirro Profile Picture
    25 on at

    Hello guys i came here because i have an exception.

    I followed the steps described in this tutorial, that you send me in your response Kokulan : .

    Everything was good until i executed my code. I got an exception saying that :  

    {"AADSTS90002: Tenant 'authorize' not found. This may happen if there are no active subscriptions for the tenant. Check with your subscription administrator.\r\nTrace ID: ID-HIDE\r\nCorrelation ID: SECOND-ID-HIDEd\r\nTimestamp: 2019-03-25 16:36:46Z"}

    I have the exact same code. And it throw that exception. I search on the web about this error and i found this stackoverflow post : [View:https://stackoverflow.com/a/53517438/7017644:750:50]

    That is saying to downgrade to the version 3.13.9. Thing that i did and BOOOOOO it now works ! So my question here is why it works when i downgrade the nuget package but not with the latest version ? Should i edit the code ? Because i want to use the latest version. I think there is a good reason why they did that.

    Here is my code :

    string api = "mydomain.api.crm4.dynamics.com/.../v9.1";
    
    AuthenticationParameters ap = AuthenticationParameters.CreateFromResourceUrlAsync(new Uri(api)).Result;
    
    var creds = new ClientCredential("APPLICATION-ID-FROM-AZURE", "SECRETFROM-AZURE");
    
    AuthenticationContext authContext = new AuthenticationContext(ap.Authority);
    var token = authContext.AcquireTokenAsync(ap.Resource, creds).Result.AccessToken;
    
    using (HttpClient httpClient = new HttpClient())
    {
        httpClient.Timeout = new TimeSpan(0, 2, 0);
        httpClient.DefaultRequestHeaders.Authorization =
            new AuthenticationHeaderValue("Bearer", token);
    
        HttpResponseMessage response =  await httpClient.GetAsync(api + "/contacts?top=1");
    
        Console.WriteLine(response.Content);
    }

    Thanks to read me ! 

  • Shirro Profile Picture
    25 on at

    Any idea ?

  • Verified answer
    Kokulan Profile Picture
    18,054 on at

    Hi

    Its a known bug in ADAL and i don't think it has been fixed yet. You will have to use the downgraded one until a fix is out.

    This has been reported as bug : [View:https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/1410:750:50]

    Please see below

    5657.ScreenClip-_5B00_342_5D00_.png

    kelvinbytes.wordpress.com/.../oauth

    Hope this helps

  • Shirro Profile Picture
    25 on at

    GREAT ! Thanks for the quick answer !

    I will use the downgraded version then until they fix the bug.

    Have a nice day !

  • Shirro Profile Picture
    25 on at

    Hey guys to use the latest version of ADAL with the code i posted above you have to replace :

    AuthenticationContext authContext = new AuthenticationContext(ap.Authority);

    by : 

    AuthenticationContext authContext = new AuthenticationContext("login.microsoftonline.com{TENANT GUID YOU CAN FIND IN AZURE}");


    It fixed the exception for me (thanks stackoverflow). So it's a temporary fix waiting the official fix. I hope it can help someone !

    Peace !

  • Kokulan Profile Picture
    18,054 on at

    Thanks for sharing

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans