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)
- Login to the Azure portal
- Click on the Create new resource button
- Search for SignalR service
- Fill in the required fields and click create
- When the resource is created (it will take a couple of minutes) click on the resource and select Keys.
- Note the Host name and Primary Connection string.
Running the Azure functions
- 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)
- The key AzureSignalRConnectionString should be set to the Primary Connection string value from step 6 in the previous section.
- To run the Cosmos DB locally you need to download the emulator. Follow the steps here Cosmos DB Emulator
- Add the settings to local.settings.json
- 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)
- Now run the Communication project and the following should appear:
Success! The server is now running locally :)
Running the Blazor client
- Open another instance of Visual Studio and the solution Battleships.BlazorUI. (Keep the other one running so the functions can be called)
- Run the Battleships.BlazorUI project
- 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 :)