Publishing to staging

Let's carry out the following steps to deploy our backend to a staging environment:

  1. In Solution Explorer, right-click on the QandA project and select Publish...
  2. Select the New option to create a new publish profile:

  1. Select Create New on the App Service tab and click Create Profile.
  2. In the dialog that appears, enter the name for the app service. This is going to be the service to host our backend in the staging environment. Note down the name you choose because we'll eventually reference this in the frontend project.

  1. Click on the Create a SQL Database option. We are going to use the database server we have already provisioned, but create a new database within it for the staging environment. Remember that these settings need to be reflected in the DefaultConnection setting in appsettings.Staging.json.
  2. We then click on the Create button to create the new app service and database, which will take a few minutes.
  3. We can then publish our code to the Azure services by clicking the Publish button. Again, this will take a few minutes to complete.
  4. A browser window will eventually open that points to the new app service. However, our app service will be referencing the production database at the moment because this is the default environment if not specified.
  5. We need to tell our new app service that it is the staging environment. Let's go to the Azure portal and select the staging app service in the App Services area.
  6. In the Settings area, select Configuration and go to the Application settings tab.
  7. Under Application settings, click the New application setting option and enter ASPNETCORE_ENVIRONMENT as the name and Staging as the value, and then click the OK button followed by the Save button. This creates an environment variable called ASPNETCORE_ENVIRONMENT with the Staging value. ASP.NET Core will look at this variable and then use the appsettings.Staging.json file for its configuration settings:

That completes the deployment of our app to a staging environment.

That's great progress! Azure works beautifully with Visual Studio. In the next section, we are going to turn our attention to the frontend and make changes so that it will work in the Azure staging and production environments as well as in development. 

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

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