Dynamic port selection makes perfect sense, as HttpPlatformHandler has a feature to restart your web app and there isn't a guarantee that the same port is always available.
You don't need extra ARR/URL rewrite rules with HttpPlatformHandler (unless you try to perform generic rewriting like HTTP to HTTPS), and you don't need to access HTTP_PLATFORM_PORT
yourself.
Update: Mar 2025
In case you want to fully take control of the port number between IIS and your application server, instead of depending on HttpPlatformHandler's random choice, HttpPlatformHandler v2 (https://github.com/lextudio/httpplatformhandlerv2) allows you to make your own decision, with sample settings as below,
<httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\node.log" startupTimeLimit="20" processPath="C:\Program Files\nodejs\node.exe" arguments=".\node_modules\next\dist\bin\next start">
<environmentVariables>
<environmentVariable name="PORT" value="4000" />
<environmentVariable name="NODE_ENV" value="production" />
<environmentVariable name="DEBUG" value="socket*" />
<environmentVariable name="HTTP_PLATFORM_PORT" value="4000" />
</environmentVariables>
</httpPlatform>
You can see that by setting an explicit port of 4000, the backend Node.js server will monitor port 4000 instead of a random port and you can access the same default page using http://localhost:4000. IIS/HttpPlatformHandler v2 in this case will forward the incoming traffic to port 4000 and enable reverse proxy rules.
This is still different from runnning your Node.js server on port 4000 and use IIS/ARR as reverse proxy, because HttpPlatformHandler still manages the Node.js process for you so things like implicit reverse proxy rules, application pool recycle support, app_offline.htm support, etc. continue to work as you might expected. With ARR you lose all of them and have to manage Node.js processes fully on your own.
Note that this behavior is only possible with HttpPlatformHandler v2 (as it inherites this feature from ASP.NET Core module). The original v1.2 from Microsoft doesn't support it.