<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.8.7-CVE.2020.14001">Jekyll</generator><link href="https://dylerch.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://dylerch.com/" rel="alternate" type="text/html" /><updated>2020-08-01T06:43:49+00:00</updated><id>https://dylerch.com/feed.xml</id><title type="html">dylerch</title><subtitle></subtitle><author><name>Dylan Lerch</name></author><entry><title type="html">Minecraft Overviewer on an Azure storage static website</title><link href="https://dylerch.com/2020/05/06/minecraft-overviewer-on-an-azure-storage-static-website.html" rel="alternate" type="text/html" title="Minecraft Overviewer on an Azure storage static website" /><published>2020-05-06T23:00:00+00:00</published><updated>2020-05-06T23:00:00+00:00</updated><id>https://dylerch.com/2020/05/06/minecraft-overviewer-on-an-azure-storage-static-website</id><content type="html" xml:base="https://dylerch.com/2020/05/06/minecraft-overviewer-on-an-azure-storage-static-website.html">&lt;p&gt;I recently started a &lt;a href=&quot;https://www.minecraft.net&quot;&gt;Minecraft&lt;/a&gt; server on a cheap Azure VM. I like to run &lt;a href=&quot;https://overviewer.org&quot;&gt;Minecraft Overviewer&lt;/a&gt; to generate a fancy map. The rendered map looks like this, you can scroll around and zoom, it’s great:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/minecraft-overviewer.png&quot; alt=&quot;Rendered Minecraft map, focused on a village with a river running through the centre&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I’m serving the map from an Azure Storage Account using the static website feature. I’ll go through how I’ve set it up:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Render the map on the same machine as the Minecraft server (saves copying files between machines)&lt;/li&gt;
  &lt;li&gt;Upload to Azure Storage with &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10&quot;&gt;AzCopy&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Set up to run every day (early morning)&lt;/li&gt;
&lt;/ol&gt;

&lt;!--more--&gt;

&lt;h2 id=&quot;rendering&quot;&gt;Rendering&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;To install Overviewer, follow the instructions on the &lt;a href=&quot;http://docs.overviewer.org/en/latest/&quot;&gt;Overviewer Documentation&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To define what to render, I’m using the &lt;a href=&quot;http://docs.overviewer.org/en/latest/config/&quot;&gt;configuration file&lt;/a&gt;. My config file looks like this:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;worlds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;world&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;home/me/path/to/minecraft/world&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;renders&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;normal&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;s&quot;&gt;&quot;world&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;world&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;s&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;World&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;s&quot;&gt;&quot;rendermode&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;smooth_lighting&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;outputdir&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/home/me/path/to/output&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To run it:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/home/me/path/to/overviewer.py &lt;span class=&quot;nt&quot;&gt;--config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/home/me/path/to/world.config
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This generates the map as a website and saves it to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/home/me/path/to/output&lt;/code&gt;. Once this is done (it takes a while) I upload it to an &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/storage/common/storage-account-overview&quot;&gt;Azure Storage Account&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;rendering-a-copy&quot;&gt;Rendering a copy&lt;/h3&gt;
&lt;p&gt;I found that if anyone is in the world when the render runs (and you’re rendering the live world file) the chunks people are working in can render incorrectly. &lt;a href=&quot;http://docs.overviewer.org/en/latest/running/#if-you-copy-your-world-before-you-render-it&quot;&gt;Be careful when copying the map before rendering&lt;/a&gt; though, Overviewer uses the file modified dates to determine if chunks need to be re-rendered.&lt;/p&gt;

&lt;p&gt;As recommended, I’m using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-p&lt;/code&gt; flag (I’m running this on Ubuntu) when copying to preserve modified dates. It seems to be working nicely. My copy command looks like this:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; /home/me/path/to/minecraft/server/world/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; /home/me/path/to/minecraft/world
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;uploading&quot;&gt;Uploading&lt;/h2&gt;
&lt;h3 id=&quot;set-up-the-storage-account&quot;&gt;Set up the storage account&lt;/h3&gt;
&lt;p&gt;To enable the static website on the storage account:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Open the storage account&lt;/li&gt;
  &lt;li&gt;Select &lt;em&gt;Static website&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Set static website to &lt;em&gt;Enabled&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Enter &lt;em&gt;index.html&lt;/em&gt; as the &lt;em&gt;Index document name&lt;/em&gt; - this is the entry point for the website generated by Overviewer&lt;/li&gt;
  &lt;li&gt;Click &lt;em&gt;Save&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/azure-static-website-annotated.png&quot; alt=&quot;Screenshot of Storage Account in Azure Portal. Showing Static website section selected, static website enabled, and 'index.html' as the Index document name.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Enabling this creates a new container named &lt;em&gt;$web&lt;/em&gt;. This is where the Overviewer render files will be uploaded.&lt;/p&gt;

&lt;h3 id=&quot;authenticating-with-the-storage-account&quot;&gt;Authenticating with the storage account&lt;/h3&gt;
&lt;p&gt;I’ve made use of a &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview&quot;&gt;System assigned managed identity&lt;/a&gt; for authenticating between the VM and the Storage Account. With this, I don’t have to manage any password or tokens - Azure manages this for me.&lt;/p&gt;

&lt;h4 id=&quot;enable-managed-identity&quot;&gt;Enable managed identity&lt;/h4&gt;
&lt;p&gt;To set up the managed identity:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Open the virtual machine page&lt;/li&gt;
  &lt;li&gt;Select &lt;em&gt;Identity&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Set status to &lt;em&gt;On&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Click &lt;em&gt;Save&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This creates a new managed identity assigned to the virtual machine.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/enable-managed-identity-annotated.png&quot; alt=&quot;Screenshot of VM in Azure Portal. Showing Identity section selected, System assigned tab shown, with status set to 'On'.&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;set-up-storage-account-permissions&quot;&gt;Set up storage account permissions&lt;/h4&gt;
&lt;p&gt;The identity that was just created can’t do anything. To give it permissions to upload to the storage account:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Open the storage account&lt;/li&gt;
  &lt;li&gt;Select &lt;em&gt;Access control (IAM)&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Click &lt;em&gt;Add &amp;gt; Add role assignment&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Select &lt;em&gt;Storage Blob Data Contributor&lt;/em&gt; for Role&lt;/li&gt;
  &lt;li&gt;Assign access to: &lt;em&gt;Virtual Machine&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Select the subscription the virtual machine is in&lt;/li&gt;
  &lt;li&gt;Select the virtual machine&lt;/li&gt;
  &lt;li&gt;Click &lt;em&gt;Save&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/setup-storage-permissions-annotated.png&quot; alt=&quot;Screenshot of Storage Account in Azure Portal. Showing Access control section selected, Role assignments tab shown. New role assignment modal shown with Storage Blob Data Contributor roles, Assigning access to Virtual Machine, Minecraft virtual machine selected.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The virtual machine will only show up in this list if it has a managed identity. If you try and do this step before you enable the managed identity you won’t see anything here.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;upload-with-azcopy&quot;&gt;Upload with AzCopy&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10#download-azcopy&quot;&gt;Install AzCopy&lt;/a&gt; on the machine if you don’t have it yet.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It can take a few minutes for the role assignment to take effect. If you get permission errors when you run these next commands, just wait a bit. It took about 10 minutes to start working for me.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;First, I run the login command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;azcopy login &lt;span class=&quot;nt&quot;&gt;--identity&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--identity&lt;/code&gt; flag in this command tells AzCopy to log in using the System Assigned Managed Identity.&lt;/p&gt;

&lt;p&gt;Next, upload the Overviewer output:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;azcopy &lt;span class=&quot;nb&quot;&gt;sync&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--delete-destination&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/home/me/path/to/output&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://&amp;lt;storage-account&amp;gt;.blob.core.windows.net/%24web&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;I’m using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sync&lt;/code&gt; command so it uploads straight in to the container, rather than also copying the containing folder like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy&lt;/code&gt; does. I’m sure there is a way to get &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy&lt;/code&gt; to not upload with the containing folder, but &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sync&lt;/code&gt; worked so I’m rolling with that.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Then it’s done.&lt;/strong&gt; Navigating to the &lt;em&gt;Primary endpoint&lt;/em&gt; that was shown on the &lt;em&gt;Static website&lt;/em&gt; page of the storage account will show the map!&lt;/p&gt;

&lt;h3 id=&quot;bandwidth&quot;&gt;Bandwidth…&lt;/h3&gt;
&lt;p&gt;If you have the Storage Account and the VM in the same Azure region, the bandwidth for the upload should be free. That said, if enough people start viewing the map you could still end up with a pretty decent bandwidth.&lt;/p&gt;

&lt;h2 id=&quot;automating&quot;&gt;Automating&lt;/h2&gt;
&lt;p&gt;This works great and all, but I don’t plan on logging in to run this every time I want to update the map, so I’ve automated it with &lt;a href=&quot;https://en.wikipedia.org/wiki/Cron&quot;&gt;cron&lt;/a&gt;. I’m way out of my depth with Linux anything, so I just followed this &lt;a href=&quot;https://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/&quot;&gt;How To Add Jobs To cron Under Linux or UNIX&lt;/a&gt; guide.&lt;/p&gt;

&lt;p&gt;In summary:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;crontab -e&lt;/code&gt; to open the cron editor&lt;/li&gt;
  &lt;li&gt;Add &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0 16 * * * /bin/bash -c /home/me/path/to/render-and-upload.sh&lt;/code&gt; to run it every morning at 2am (I’m in AEST and machine is running in UTC, so 1600 UTC is 0200 AEST)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Overviewer is pretty resource-hungry. If you’re rendering on the same machine as the server, probably don’t run it when people are playing.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;script&quot;&gt;Script&lt;/h3&gt;
&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;render-and-upload.sh&lt;/code&gt; script that does all the work looks something like this:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Copy before rendering&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; /home/me/path/to/minecraft/world/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; /home/me/path/to/minecraft/server/world/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; /home/me/path/to/minecraft/world

&lt;span class=&quot;c&quot;&gt;# Render&lt;/span&gt;
/home/me/path/to/overviewer.py &lt;span class=&quot;nt&quot;&gt;--config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/home/me/path/to/world.config

&lt;span class=&quot;c&quot;&gt;# Authenticate&lt;/span&gt;
azcopy login &lt;span class=&quot;nt&quot;&gt;--identity&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Clear the folder before uploading. Sync is meant to clear out files that should not be there, but I issues with sync detecting changes 100% and left the map looking strange.&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;azcopy remove &lt;span class=&quot;nt&quot;&gt;--recursive&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://&amp;lt;storage-account&amp;gt;.blob.core.windows.net/%24web&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Upload&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;azcopy &lt;span class=&quot;nb&quot;&gt;sync&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--delete-destination&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/home/me/path/to/output&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://&amp;lt;storage-account&amp;gt;.blob.core.windows.net/%24web&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;And it’s done for real&lt;/strong&gt;. Automated map generation and upload with no usernames, passwords, or tokens floating around.&lt;/p&gt;</content><author><name>Dylan Lerch</name></author><category term="azure" /><category term="minecraft" /><summary type="html">I recently started a Minecraft server on a cheap Azure VM. I like to run Minecraft Overviewer to generate a fancy map. The rendered map looks like this, you can scroll around and zoom, it’s great: I’m serving the map from an Azure Storage Account using the static website feature. I’ll go through how I’ve set it up: Render the map on the same machine as the Minecraft server (saves copying files between machines) Upload to Azure Storage with AzCopy Set up to run every day (early morning)</summary></entry></feed>