MultiConnectMultiConnectDocs Website home
MultiConnectCloud › API Deployments

5. Inside the container

What is set for you

Variable Value
PORT The port your service must listen on
MULTICONNECT_DEPLOYMENT_ID This deployment's id
MULTICONNECT_BUILD_VERSION The build number currently running
ASPNETCORE_URLS .NET only. Makes Kestrel listen on PORT on all addresses, with no code

Listen on all addresses (0.0.0.0), not localhost. A service that listens on localhost runs but cannot be reached.

The health check

MultiConnectCloud sends GET /health to each container. A 2xx answer means "send me traffic". Anything else, or no answer, means the container gets no traffic, and during a deploy it counts against the new build becoming healthy.

Script 5.1: A minimal .NET API

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

// ASPNETCORE_URLS is set for you, so no port here.
app.MapGet("/health", () => Results.Ok("ok"));
app.MapGet("/", () => new { hello = "world" });

app.Run();

Script 5.2: A minimal Node.js API

const http = require('http');
const port = Number(process.env.PORT || 8080);

http.createServer((req, res) => {
  if (req.url === '/health') { res.writeHead(200); return res.end('ok'); }
  res.writeHead(200, { 'content-type': 'application/json' });
  res.end(JSON.stringify({ hello: 'world' }));
}).listen(port, '0.0.0.0');

Your environment variables

Set them in Environment Variables when you create the deployment, or later with Update.

Rule Detail
Names Start with a letter or underscore, then letters, numbers and underscores. Each name once
Reserved names PORT, ASPNETCORE_URLS, ASPNETCORE_HTTP_PORTS, ASPNETCORE_HTTPS_PORTS, DOTNET_RUNNING_IN_CONTAINER, HOSTNAME, and anything starting with MULTICONNECT_. These are set by the platform
Secrets Set Secret to Yes. The value is stored encrypted and shown as ******** after saving. Leave the mask as it is to keep the saved value
.env files Upload .env File reads KEY=VALUE lines. A key already in the list has its value replaced

Script 5.3: An example .env file

DATABASE_URL=your-connection-string
LOG_LEVEL=info
PAYMENTS_API_KEY=your-key

Changing an environment variable redeploys your current build so the new value takes effect.

The start command

The start command is run as written, split on spaces, without a shell. So: