A Full-Stack Web App Using Blazor WebAssembly and GraphQL—Part 7
Tags: blazor, csharp, dotnet, graphql
Published: 2022-12-12 04:26:07

---
title: A Full-Stack Web App Using Blazor WebAssembly and GraphQL—Part 7
published: true
date: 2022-12-01 12:06:34 UTC
tags: blazor, csharp, dotnet, graphql
canonical_url: https://www.syncfusion.com/blogs/post/a-full-stack-web-app-using-blazor-webassembly-and-graphql-part-7.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vx1rttni82ohnf1twka6.png
---

In the previous [article](https://www.syncfusion.com/blogs/post/a-full-stack-web-app-using-blazor-webassembly-and-graphql-part-6.aspx "Blog: A Full-Stack Web App Using Blazor WebAssembly and GraphQL: Part 6") of this series, we learned how to implement client-side state management in our application. We also added a watchlist to it.

This article will show you how to deploy our MovieApp application to the IIS and Azure app services.

## Publish Blazor server app in IIS

### Configure the Windows machine for deployment

For this tutorial, I am using a Windows 11 system.

#### Enable IIS on Windows

Open the control panel on your Windows machine. Click **Programs and Features**. A new window will open. Click **Turn Windows feature on or off** under the menu on the left side. A new window called **Windows feature** will open.

Search for **Internet Information Services** (IIS). Expand the IIS option by clicking on the plus icon. You will find a list of sub-options under it. Select all the options under **Web Management Tools** & **World Wide Web Services**. Refer to the next image.

![Windows Features dialog](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Enable-IIS-on-Windows-1.png)  
Click **OK** to install IIS.

#### Install URL rewrite module

The URL rewrite module enables the site administrator to create customized rules to implement URLs that are easier for users to remember and are SEO-friendly, as well.

To learn more, please refer to [the Microsoft documentation](https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-the-url-rewrite-module "Using the URL Rewrite Module documentation").

Navigate to [URL Rewrite](https://www.iis.net/downloads/microsoft/url-rewrite "URL Rewrite in IIS"). Click **Install this extension** to download the URL rewrite module to your machine.

Refer to the following image.

![Install the URL rewrite extension](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Install-URL-rewrite-module.png)  
Install the downloaded package on your machine.

#### Install .NET Core hosting bundle

Navigate to [.NET](https://dotnet.microsoft.com/en-us/download/dotnet "Download .NET page") official site. Click on the latest stable version of .NET. We are using .NET 6.0 in our app, so we will click on that option.

Refer to the following image.

![Download the latest .NET version](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Install-.NET-Core-hosting-bundle.png)  
A new window will appear. In the **Run apps – Runtime** section, observe that the link to download the hosting bundle is provided corresponding to the **Windows** option. Refer to the following image.

![Download and install the .NET Core hosting bundle for Windows](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Download-and-install-the-.NET-Core-hosting-bundle-for-Windows.png)Download and install the .NET Core hosting bundle for Windows.

**<u>Important Notes</u>**

- Install the .NET Core hosting bundle after installing IIS.
- Restart your machine after installing the .NET Core hosting bundle.

### Publish the Blazor application

Once the configuration of the Windows machine is complete, let’s focus on publishing our Blazor application:

1. Right-click the **MovieApp.Server** project and then click **Publish**.
2. In the Publish window that appears, click the **Folder** link and then click **Next**.
3. In the next window, provide the path of the folder where you want your application to be published and then click **Finish**.
4. Finally, click **Publish** at the top. The process of building and publishing will start.

Refer to the following image to see all the steps in action.  
 ![Publish the Blazor application](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Publish-the-Blazor-application.gif)  
If there are no errors, then the app will be published successfully in the folder path you have provided.

Next, let’s focus on configuring the IIS.

### Configuring IIS

To open the IIS manager:

1. Open the **Control Panel** from the start menu.
2. In the category view of the Control Panel, open **System and Security** and select **Administrative Tools**.
3. Here, you’ll find the Internet **Information Service (IIS) Manager**. Double-click on it to open it.

Right-click on **Sites** in the left pane and then select **Add Website**. An **Add Website** window will appear. Fill out the details:

- **Site name** : Enter the site’s name as per your choice. We will use the name **MovieApp** for this demo.
- **Physical path** : Provide the path of the folder where you have published the Blazor application.
- **Host name** : Provide the URL to be used to access the application in the browser. We will use  **movieapp.com** for this demo.

Click **OK** to create the website.

The next step is to configure the application pool. An application pool corresponding to our website is created automatically once we add a new website. The name of the application pool is the same as the **s**** ite **** name** we provided while creating the website.

Select the **Application Pools** link and double-click on the pool **movieapp**. A new edit application pool window will appear. Select **No Managed Code** from the .NET CLR version dropdown and then click **OK**.

Refer to the next image to see all the steps in action.  
 ![Configuring IIS](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Configuring-IIS.gif)

### Configure the DNS host

The final step is to configure the DNS host file of the machine.

Navigate to the _ **C:\Windows\System32\drivers\etc** __ _folder on your machine. Open the **hosts** file using a text editor of your choice.

Add an entry for the website URL in this file corresponding to the localhost IP address. Refer to the following image.

![Configure the DNS host file](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Configure-the-DNS-host.png)

This configuration is required to ensure that we can access our deployed website on the local machine.

### Execution and troubleshooting

Open a browser and navigate to [Movie App](http://movieapp.com/ "movieapp page") page. You can see a page similar to the one in the following screenshot.

![Movie App page](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Execution-and-troubleshooting.png)  
You can see that the movie posters are not being displayed. Let’s understand why this is happening and how we can fix it.

In our app, we have used the same database for the deployed environment and development environment. While running the app after deployment, it will try to fetch the **posterPath** from the **Movie** table of the database and try to locate the posters in the **Poster** folder of the server. But the posters are not available where we have published our app. So, we need to add the images to the Poster folder to resolve the issue.

Open the **Poster** folder in **MovieApp.Server** project and copy all the images. Navigate to the folder where you have published the app. You can see that a **Poster** folder is already created. Paste the copied images here.

If you refresh the website, you will see the posters, as shown in the following image.

![Deploying the app to IIS](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Deploying-the-app-to-IIS.png)  
We have successfully deployed the app to IIS. Let’s learn how to deploy it to Azure App Service.

## Publish Blazor server app in MS Azure

Please create an Azure [subscription account](https://azure.microsoft.com/en-in/ "Azure subscription account").

### Create a SQL Server resource on the Azure portal

Now, create a SQL Server on Azure to handle our database operations. Open the [Microsoft Azure ](https://portal.azure.com/ "Microsoft Azure")portal.

Click **Create a resource**. On the next page, locate the **SQL Database** resource and click **Create**. Refer to the next image.

![Create a SQL Server resource on the Azure portal](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Create-a-SQL-Server-resource-on-the-Azure-portal.png)  
A new page with the title “ **Create SQL Database** ” will appear. On this page, you will be asked to furnish the details for your SQL database.

You can provide the details in the **Basics** tab:

- **Subscription** : Select the subscription type for your Azure account from the drop-down.
- **Resource group** : You can either select an existing resource group name from the dropdown or create a new resource group by clicking **Create new**.
- **Database name** : Provide a unique name for the database. This database name must satisfy the following validation criteria.

![Basic requirements for providing Database name](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Database-name.png)

- **Server** : Click **Create new** to create a new server for the database. A new window will appear. Provide the details:
  - **Server name** : Provide a unique server name.
  - **Location** : Provide a location.
  - **Authentication Method** : Select an authentication method as per your requirement. For this app, we will use **SQL authentication**. Configure the Server admin login and password.

Refer to the following image to understand the server configuration.  
 ![Create SQL database Server window](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Create-SQL-database-Server.png)

- **Compute + storage** : Click **Configure database**. In the next window, select the option you need from the **service tier** dropdown.

Click **Next** at the bottom until you reach the **Review + create** tab. Click **Create** at the bottom of this tab to create the SQL database.

Refer to the following image.  
 ![Create SQL Database window](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Configure-database.gif)

### Update the connection string in the application

Once the database is created, navigate to the database resource page. We must allow access to this resource through the internet using a public IP address. This will allow us to connect to this database from our local machine.

Click **Set Server Firewall** at the top. Under the Public access tab, click **Selected networks**. Click **Save** at the bottom.

We also need other Azure resources, such as the Azure App Service, to access our database. Therefore, select **Allow Azure services and resources to access this server** at the bottom of the page in the **Exceptions** section. Once again, click **Save** at the bottom.

The next step is to fetch the connection string.

Click **Connection strings** in the **Settings** menu on the left side of the page. Select the **ADO.NET**  tab and copy the connection string.

Refer to the following image.  
 ![Update the connection string in the application](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Update-the-connection-string-in-the-application.gif)  
Open the **appsettings.json** file in your project and replace the existing connection string of the local database with the connection string of Azure SQL Server.

Refer to the next image.  
 ![Replace the existing connection string of the local database with string of Azure SQL Server](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Replace-the-existing-connection-string-of-the-local-database.png)

### Creating database objects

The Azure SQL database does not contain the tables that we are using in our app. We will create them using SSMS from our machine.

Open SSMS and connect to the Azure SQL Server by furnishing the following information:

- **Server name** : Provide the server name as given in the connection string.
- **Authentication** : Select **SQL Server Authentication**.
- **Login** : Provide the user ID for the server.
- **Password** : Provide the password for the server.

Refer to the following image.

![Creating database objects](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Creating-database-objects.png)  
Click **Connect**.

When you are trying to connect to the Azure SQL Server from your local machine, it will ask you to set up a firewall rule. Log in with the credentials of your Azure account. Select **Add my client IP address** and click **OK**.

Refer to the following image.

![New Firewall Rule dialog](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Connect-to-the-Azure-SQL-Server-from-your-local-machine.png)  
Once the connection is made, create all the required tables in the database. You can get the SQL scripts for creating the tables from the **Set up the database** section of [Part 1](https://www.syncfusion.com/blogs/post/a-full-stack-web-app-using-blazor-webassembly-and-graphql-part-1.aspx "Blog: A Full-Stack Web App Using Blazor WebAssembly and GraphQL: Part 1") of this series. Run these scripts to generate the tables.

Now, run the application from Visual Studio. You will be able to see the following screen.  
 ![Run the application from Visual Studio](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Run-the-application-from-Visual-Studio.png)  
Since the tables are empty, there is no movie data to display. However, you can see the genre data.

### Publish the Blazor application to Azure

Right-click the **MovieApp.Server** project and click **Publish**. A Publish window will open asking you to select a target to publish. Select **Azure** and click **Next**.

You will be asked to connect to the Azure account from Visual Studio. Once the login is successful, it will ask you to select the Azure service to host the application. Select **Azure App Service (Windows)** and click **N**** ext**.

The next window will list all the app services you have in your account. We will create a new app service instance for this app. Click **Create New**.

A new window will appear requesting you to provide the app service details. Provide a unique name for your app service. The name of the app service must be universally unique and should not be used by anybody else. Select the subscription name and resource group as per your account configuration. You can select an existing hosting plan or create a new one.

Refer to the following image.  
 ![App Service window](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Publish-the-Blazor-application-to-Azure-1.png)  
Click **Create** to create the Azure App Service instance. Select the newly created app service name and click **Finish**.

On the next page, you can verify all the information you have provided and then click **Publish** at the top. The process of building and publishing will start. After the publication is successful, the URL will launch in your machine’s default browser.

The website URL will be _ **<app service name>.azurewebsites.net**._ You can see the webpage looks like the following image.

![Created application](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Create-the-Azure-App-Service-instance.png)  
Currently, there is no data displayed since the DB tables are empty. Log in as the admin user and add some movie data. You can validate that the application is working as expected.

The application we have created in this series of articles is available at [here](https://blazorwasmgraphql.azurewebsites.net/ "Creating a Blazor WebAssembly app using GraphQL online demo").

### Upload the default poster image to the Azure App Service

We need to add the default poster image to the Azure App Service. This will ensure that the default poster image is displayed if the user fails to upload a poster for a movie.

We will upload the required file via the Kudu console.

**Note:** To learn more about the Kudu console, please refer to [the Microsoft documentation  
](https://learn.microsoft.com/en-us/azure/app-service/resources-kudu "Kudu service overview"). Open the URL **_https://<app service name>. scm.azurewebsites.net_** to open the Kudu console corresponding to your app service.

Select **Debug console ->**  **PowerShell** from the menu bar at the top. It will list the file system of our app service. Navigate to **Site ->**  **wwwroot ->**  **Poster** folder. Drag the default poster image to this path. The file is uploaded and will be available for the app service to consume.

Refer to the following image.  
 ![Upload the default poster image to the Azure App Service](https://www.syncfusion.com/blogs/wp-content/uploads/2022/12/Upload-the-default-poster-image-to-the-Azure-App-Service.gif)

## Summary

Thanks for reading! In this article, we learned to configure IIS on a Windows machine and deploy our Blazor application on it. We learned about deploying and publishing a Blazor application on Azure. We created a SQL Server database on Azure and configured it to use as the database provider for our application. We finally deployed the Blazor application on the Azure App Service.

This article concludes the series on Blazor and GraphQL.

Syncfusion’s [Blazor](https://www.syncfusion.com/blazor-components "Blazor UI components library") component suite offers over 70 UI components. They work with both server-side and client-side (WebAssembly) hosting models seamlessly. Use them to build marvelous apps!

If you have any questions or comments, you can contact us through our [support forums](https://www.syncfusion.com/forums "Syncfusion support forums"), [support portal](https://support.syncfusion.com/ "Syncfusion support portal"), or [feedback portal](https://www.syncfusion.com/feedback/ "Syncfusion feedback portal"). We are always happy to assist you!

## Related blogs

- [A Full-Stack Web App Using Blazor WebAssembly and GraphQL: Part 1](https://www.syncfusion.com/blogs/post/a-full-stack-web-app-using-blazor-webassembly-and-graphql-part-1.aspx "Blog: A Full-Stack Web App Using Blazor WebAssembly and GraphQL: Part 1")
- [A Full-Stack Web App Using Blazor WebAssembly and GraphQL: Part 2](https://www.syncfusion.com/blogs/post/a-full-stack-web-app-using-blazor-webassembly-and-graphql-part-2.aspx "Blog: A Full-Stack Web App Using Blazor WebAssembly and GraphQL: Part 2")
- [A Full-Stack Web App Using Blazor WebAssembly and GraphQL: Part 3](https://www.syncfusion.com/blogs/post/a-full-stack-web-app-using-blazor-webassembly-and-graphql-part-3.aspx "Blog: A Full-Stack Web App Using Blazor WebAssembly and GraphQL: Part 3")
- [A Full-Stack Web App Using Blazor WebAssembly and GraphQL—Part 4](https://www.syncfusion.com/blogs/post/a-full-stack-web-app-using-blazor-webassembly-and-graphql-part-4.aspx "Blog: A Full-Stack Web App Using Blazor WebAssembly and GraphQL—Part 4")
- [A Full-Stack Web App Using Blazor WebAssembly and GraphQL—Part 5](https://www.syncfusion.com/blogs/post/a-full-stack-web-app-using-blazor-webassembly-and-graphql-part-5.aspx "Blog: A Full-Stack Web App Using Blazor WebAssembly and GraphQL—Part 5")
- [A Full-Stack Web App Using Blazor WebAssembly and GraphQL: Part 6](https://www.syncfusion.com/blogs/post/a-full-stack-web-app-using-blazor-webassembly-and-graphql-part-6.aspx "Blog: A Full-Stack Web App Using Blazor WebAssembly and GraphQL: Part 6")