Just another programming blog

Azure, HowTo, Tips&Tricks

Pay-as-you-go TeamSpeak 3 hosting with Azure Container Instances – with storage

Introduction

My last post on TeamSpeak 3 server hosted with Azure Container Instances received a question on how to persist settings between restarts of the server. While, I didn`t need it for myself yet, I`ve managed to find a while and solve that mystery as well. Without further ado, here`s how.

Prequisites

Azure Storage Account - File Share

In order to set it up correctly, we need to create Azure Storage Account (general purpose). Here`s how to do that.

After it`s created we should go to File shares tab:
File Share tab
and create a file share with your chosen name (acishare in my case):
File Share list

Initial TeamSpeak files

Okay. Here comes the tricky part. It seems like ts3 server is freezing during the initialization for some reason if there is no database file beforehand. In order to get it, my preferred way is to run the docker container locally, mount a local storage and copy the file to the file share before running the container.

Assuming you`ve got Docker already installed:
1. Open powershell/cmd and run the following:

docker run -e TS3SERVER_LICENSE=accept -v C:/Users/Chroscielski/ts3server:/var/ts3server teamspeak:latest

// Note: C:/Users/Chroscielski/tsdir should be your local directory you want to mount into the container.
2. After running that command, we should get the credentials for later use (loginname, password, apikey and token) - write them down!
TeamSpeak 3 container output with admin credentials
TeamSpeak 3 container output with token
3. Once you\'ve got them saved, you can shut down the container (ctrl + c will do).
4. Now go to your local directory, you\'ve previously mounted into the container (in my case it is: C:/Users/Chroscielski/ts3server). You should see files like below:
Files in directory
5. Don\'t bother about all those files. The one we need is ts3server.sqlitedb. Open Azure file share, you have created before and upload that file into the root directory.
Files on share

ARM Template for container with file share mounted

In order to create our container instance, we need to use ARM template, because currently there is no possibility to do that via Azure Portal wizards.

You can see the ARM template here.

To keep things simple, you can just use the button below and use it to deploy the container into your Azure subscription:

Deploy to Azure

In my case it looks like the following:
ARM parameters

Results

After a deployment is successfull:
Successfull deployment

You can test if server persists your settings. Simply:
1. Create channel
2. Turn container off
3. Turn container on
3. Your newly created channel should still be present
4. Voilà!

Summary

There may be several different ways of achieving this, however I have found that one pretty straightforward for me. If you got any other idea, leave a comment!

Leave a Reply