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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Connecting VS Code to OnPrem Server with AAD

(0) ShareShare
ReportReport
Posted on by 5

I am trying to connect VS Code to a client's OnPrem server and I am running into problems.

The client is OnPrem, currently on version 18.1.

They use AAD authentication.

I have VS Code installed on their app server.

The MS documentation says it doesn't work with OnPrem solutions, so I set the environmentType to "Production" in the launch.json file.

Here's what my launch.json looks like:

"version": "0.2.0",
"configurations": [
{
     "name": "XXXXX",
     "request": "launch",
     "type": "al",
     "environmentType": "Production",
     "server": "http://SubDomain.MyClient.com",
     "serverInstance": "ServerInstance",
     "authentication": "AAD",
     "startupObjectId": 50022,
     "startupObjectType": "Page",
     "breakOnError": true,
     "launchBrowser": true,
     "enableLongRunningSqlStatements": true,
     "enableSqlInformationDebugger": true,
     "tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
     "schemaUpdateMode": "Synchronize",
     "port": 7059
}

Debugging is enabled in their server. The Web Base URL is populated. 
The first time I tried this I got an invitation to microsoft.com/devicelogin and a code to enter. Once I had done that, the connection fails with this message in the terminal:
[2021-09-30 11:44:47.08] Targeting Dynamics 365 Business Central with tenant AAD domain name 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.
[2021-09-30 11:44:47.09] Sending request to api.businesscentral.dynamics.com/.../metadata
[2021-09-30 11:44:47.71] The request for path /v2.0/production/dev/metadata failed with code NotFound. Reason: Not Found
[2021-09-30 11:44:47.71] Sending request to api.businesscentral.dynamics.com/.../webendpoint
[2021-09-30 11:44:47.76] The request for path /v2.0/production/dev/webendpoint failed with code NotFound. Reason: Not Found
Any suggestions would be greatly appreciated.
I have the same question (0)
  • Marco Mels Profile Picture
    on at

    Hello,

    The environment type should be set to OnPrem.

    Hope it helps.

    Thanks.

  • Lloyd Bailey Profile Picture
    5 on at

    I should have explained better. We changed it to "Production" because "OnPrem" did not work either.

    We were grasping at straws at that point because the error we get with is "Error: An internal error has occurred" and there's nothing in the Event Viewer that is really helpful (shocker). There is a Security log that says "The Windows Filtering Platform has blocked a packet" but that is all.

  • Suggested answer
    Marco Mels Profile Picture
    on at

    Good day,

    Now I see the mistake. With OnPrem you cannot use AAD authentication. You need to set it to UserPassword. Then it will work.

    On NST, you should set authentication type to NavUserPassword. NavUserPassword on NST supports both Azure AD and NavUserPassword.

    This is written somewhere in the docs.

    Hope it helps.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,917

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,161 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,025 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans