Error 500 1002 When Deploying Nodejs Bot In App Service

Adrian Jenkins
5 min readAug 30, 2023

Simplified guide on how I resolved my 500 1002 when I deployed Nodejs Echo Bot sample in App Service.

Create Bot

You will need nodejs version 16.16 or higher.

Download Bot Framework emulator so we can test if it works locally or not.

Also, download Git to make our life easier:

I will use the following repo:

Follow instructions from above sample and after “npm start” open Bot Framework Emulator and set correct endpoint:


Great, we know it is working locally.

Preparing Bot Before Publish in App Service

Here is official documentation of process using Azure CLI:

Create Azure Bot

I am not going to do whole process here.

Just create Azure Bot.

Mine is SingleTenant.

Create App Service & App Service Plan

Again, nothing special here.

Just create App Service and App Service Plan. Typically, when creating App Service, it will create App Service Plan be default.

Only thing I did different is when creating App Service, I choose “Node” as runtime stack.

Also, mine is Windows.

We need App Service to use Nodejs version 16 or higher.

The way this can be achieve is by going to App Service > Environmental Variables > WEBSITE_NODE_DEFAULT_VERSION = <VERSION>

Mine is 18.12.1.

Update Project Configuration Settings

These settings are set in “.env” file.

If you do not know where are these values you can refer to this previous article:

Prepare Project Files
1. Switch to your project’s root folder.

  • For JavaScript, the root is the folder that contains the app.js or index.js file.

2. Run npm install. We already did this. What this does is to generate the “node_modules/” folder.

3. We need to generate the web.config file. For this we will need to download Azure CLI

Install the Azure CLI for Windows | Microsoft Learn

Once dowloaded run the following while in root folder:

az bot prepare-deploy --lang <language> --code-dir "."

# In our case is Javascript
az bot prepare-deploy --lang Javascript --code-dir "."

We are now ready to publish. But before doing this I will enable some logs in case they are needed.

Enabling Logs Before Publishing [ OPTIONAL ]

Open the web.config’, and right after the closing section of </handlers> tag insert the following line:

<iisnode logDirectory="iisnode" loggingEnabled="true" />

Also, create a directory called “iisnode” at root level.

Switched over to the App Service > App Service Logs

Publish Bot in App Service

Feel free to publish into App Service any way you would like to.

I am just going to just grab the contents and drop it in Kudu console inside “C:\home\site\wwwroot”.

How do you get to Kudu Console?

App Service >Advanced Tools > Go.

Debug Console > CMD and navigate to “wwwroot/” folder.

After deployment, I hope your bot is working smoothly. However, for me this was not the case.

If I visit the App Service endpoint I got a 500.

If I go to the “C:\home\LogFiles\http\RawLogs” you will see 500 1002.

2023-08-30 17:48:00 ECHOBOT1TESTING GET / <OTHER STUFF> 500 1002 2 345 1507 4914

Now, if we take a look at the FREB file in: “C:\home\LogFiles\W3SVCYOURID>”, you will see that iisnode module failed.

If you search for that status code, there is no clear answer on what triggers it.

There could be several causes for it.

My guess, as we will see, is that it cannot find some modules.

If you go to the “iisnode/” folder we created before deployment (“C:\home\site\wwwroot\iisnode”), you will find a file.

In my case it said it could not find module “restify”

But this makes no sense because “restify” module is indeed in “node_modules/” folder:

C:\home\site\wwwroot>ls node_modules/ | grep restify

At this point I decided to delete everything inside “wwwroot/” folder. To start fresh.

I zipped the folder containing the application.

Went to “wwwroot/” in Kudu and dropped the zip.

I let it finished PATIENTLY. I estimate that I gave it like 10 minutes.

After this, I visited my endpoint “URL/02.echo-bot/”. Previously I had either 500.1002.

But now you can see nodejs application is actually handling requests:

Went to Azure Bot and configured the correct endpont.

NOTE: as my app is inside wwwroot/ the actual endpoint would be:


BECAUSE OF THE WAY I SET IT UP, I need to change index.js so that it listens to incoming requests in “/02.echo-bot/api/messages” instead of “/api/messages”.

Tested in Web Chat:

In Summary

  • Probably 500 1002 is because it cannot find modules. Either they are not there, or they are and it cannot find them.
  • Try starting from zero and re-deploy the app. Most probably this is cause because something went wrong during first deployment.
  • Make Sure App Service is using Nodejs version 16 or higher.
  • Enabling logs can take you a long way.