4 Simple Steps to Run D Language in Azure Websites

I shameless stole these steps from 4 Simple Steps to Run Go Language in Azure Websites. This post is simply a transliteration to D. Thank you very much to Wade Wegner for the original post.

4 Simple Steps

  1. Create your Azure Website in Azure Portal.
    1. Configure FTP deployment

FTP Configuration

2. Run dub init vibed_hello_world --type=vibe.d and change the default app.d to read the port from an environment variable. Docs

import vibe.d;

shared static this()
	import std.process;
	import std.conv;

	immutable port = environment["HTTP_PLATFORM_PORT"]; //Use the port IIS tells us to.

	auto settings = new HTTPServerSettings;
	settings.port = to!ushort(port);
	settings.bindAddresses = ["::1", ""];
	listenHTTP(settings, &hello);

	logInfo("Please open" ~ port ~ "/ in your browser.");

void hello(HTTPServerRequest req, HTTPServerResponse res)
	res.writeBody("Hello, World!");

3. Create Web.Config

<?xml version="1.0" encoding="UTF-8"?>
			<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
		<httpPlatform processPath="d:\home\site\wwwroot\vibed_hello_world.exe" 

4. Upload binaries and DLLs to Azure! Upload to FTP Server