Publishing to production

Let's carry out the following steps to deploy our backend to production:

  1. In Solution Explorer, right-click on the QandA project and select Publish....
  2. The Publish screen opens. Select the Publish section and then click the Start button:

  1. We are then prompted to choose a publish target. Choose Create New and click the Create Profile button:

  1. The next step is to specify our Microsoft account and name the production app service. Note down the name you choose because we'll eventually reference this in the frontend project:

  1. We can also create a SQL database on this screen. Let's do this by clicking the Create a SQL Database option.
  2. In the dialog that opens, enter the database name to match what we have specified in the connection string in the appsettings.Production.json file.
  3. We need to create a new database server, so click the New... option to the right of the Database server field.
  4. Let's use the server name and credentials we specified in the connection string in the appsettings.Production.json file. 
  5. Click the OK button to confirm the server details and then the OK button on the database screen beneath it.
  6. We are taken back to the Azure App Service dialog with the details that we have just specified in the bottom-right corner.
  7. Click the Create button to create the services in Azure. This will take a few minutes to complete.

Notice the warning at the bottom of the screen:

This is a reminder that there is a SignalR Service in Azure that we could use for our real-time API. Implementing this is beyond the scope of this chapter, so we'll continue to use the real-time API within our app service.

  1. We can then publish our code to the Azure services by clicking the Publish button. Again, this will take a few minutes to complete.
  2. Just before deployment is complete, the following prompt may appear:

Choose Yes to turn web sockets on in our app service.

  1. Eventually, a browser window will open containing the path to our deployed backend. Add /api/questions to the path in the browser:

We will see the default questions from our database. Congratulations! We have just deployed our first SQL database and ASP.NET Core app in Azure!

  1. Let's go to the Azure portal by navigating to https://portal.azure.com. Select the All resources option:

As expected, we see the services that we have just provisioned. 

Excellent! We have just successfully deployed our backend in Azure!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.43.206