Running cloudbattleships on your computer

This post is an explanation on how to setup and run my cloudbattleships app locally.

Get the code

Clone the repo. It has a couple of different projects, all created using Visual Studio 2017 Preview (15.8.1).
The first solution to open is Battleships.Communication which is the back-end of the game. This project uses Azure Functions and Cosmos DB to manage the games and players.

Setting up the Azure SignalR service

Once you have that solution opened it is time to configure the SignalR service that enables the different clients to connect to each other.
This part of the app is the only thing that cannot be run on your machine, it needs to be in Azure (hence the name)

  1. Login to the Azure portal
  2. Click on the Create new resource button
  3. Search for SignalR service
  4. Fill in the required fields and click create
  5. When the resource is created (it will take a couple of minutes) click on the resource and select Keys.
  6. Note the Host name and Primary Connection string.

Running the Azure functions

  1. In the Battleships.Communication project open the local.settings.json file (you might want to run the git-command git update-index --assume-unchanged local.settings.json first to avoid checking your settings in to git)
  2. The key AzureSignalRConnectionString should be set to the Primary Connection string value from step 6 in the previous section.
  3. To run the Cosmos DB locally you need to download the emulator. Follow the steps here Cosmos DB Emulator
  4. Add the settings to local.settings.json
  5. To check the local Cosmos connection you can run the test project after editing the Properties/launchsettings.json to the same settings as 4 for the Cosmos DB. (Again git --assume-unchanged should be run)
  6. Now run the Communication project and the following should appear:
    Success! The server is now running locally :)

Running the Blazor client

  1. Open another instance of Visual Studio and the solution Battleships.BlazorUI. (Keep the other one running so the functions can be called)
  2. Run the Battleships.BlazorUI project
  3. Once the project builds your browser should open and show the following:
    Now you can open 2 browser windows and play the game :)

Running the Xamarin Forms client

This is the same as for the Blazor project though just now you can only run the UWP client.
Once you have everything running you can deploy everything to Azure Functions, Azure Web Apps and Azure Cosmos DB to play with your friends :)