Skip to content

Latest commit

 

History

History
61 lines (37 loc) · 3.54 KB

README.md

File metadata and controls

61 lines (37 loc) · 3.54 KB

Serverless Tic Tac Toe

This is a sample of a serverless multiplayer game running in Azure using the following technologies:

This recording of the Global Azure 2023 session walks you through the code:

Watch the video

Communication flow

Communication flow

Local development

You can use the following emulators for local development:

dotnet tool install  -g Microsoft.Azure.SignalR.Emulator
cd .\src\TicTacToe.Functions
asrs-emulator start

Deployment

If you want to deploy the sample to your own Azure subscription:

  • Start by forking this repository

  • Create a resource group in your Azure subscription

  • Then you can use the deployment script in the iac folder to create the necessary resources:

    az deployment group create --resource-group my-sample --template-file iac/main.bicep --name samples-serverless-tictactoe
  • You need to provide your repository URL and a GitHub access token as parameters (the command above will ask for them). You can create an access token here (it requires Read access to metadata and Read and Write access to actions, actions variables, code, secrets, and workflows permissions for your repository).

  • Running the command will (among others) create a Function App and a Static Web App in your resource group and create a GitHub action for the Static Web App in your repository.

  • Replace the URL in appsettings.json with the URL of your Function App (keep the /api postfix).

  • Download the publish profile for the Function App that was created.

  • Create a new repository secret named AZURE_FUNCTIONAPP_PUBLISH_PROFILE and paste the XML code from the publish profile as the value.

  • Then you can copy the code from the existing GitHub action to the new action (but replace AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_RIVER_0FBF49203 with the secret name from your file).

  • You can now delete the existing GitHub action.

  • Running the GitHub action should now build and deploy the code and you should be able to run the game by accessing your Static Web App.

  • Have fun!