Skip to content

Commit

Permalink
Merge pull request #117706 from cephalin/configure-win2
Browse files Browse the repository at this point in the history
config windows apps
  • Loading branch information
PMEds28 authored Jun 17, 2020
2 parents 7534982 + b5d578e commit 6f5310b
Show file tree
Hide file tree
Showing 29 changed files with 862 additions and 230 deletions.
7 changes: 6 additions & 1 deletion .openpublishing.redirection.json
Original file line number Diff line number Diff line change
Expand Up @@ -9918,7 +9918,12 @@
},
{
"source_path": "articles/app-service-web/web-sites-php-configure.md",
"redirect_url": "/azure/app-service/web-sites-php-configure",
"redirect_url": "/azure/app-service/configure-language-php",
"redirect_document_id": false
},
{
"source_path": "articles/app-service/web-sites-php-configure.md",
"redirect_url": "/azure/app-service/configure-language-php",
"redirect_document_id": false
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,6 @@ The app name specified in the **App Service Create new** page is used as the URL

> [!div class="nextstepaction"]
> [ASP.NET with SQL Database](app-service-web-tutorial-dotnet-sqldatabase.md)
> [!div class="nextstepaction"]
> [Configure ASP.NET app](configure-language-dotnet-framework.md)
3 changes: 3 additions & 0 deletions articles/app-service/app-service-web-get-started-dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,6 @@ Advance to the next article to learn how to create a .NET Core app and connect i

> [!div class="nextstepaction"]
> [ASP.NET Core with SQL Database](app-service-web-tutorial-dotnetcore-sqldb.md)
> [!div class="nextstepaction"]
> [Configure ASP.NET Core app](configure-language-dotnetcore.md)
9 changes: 8 additions & 1 deletion articles/app-service/app-service-web-get-started-nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,13 @@ You can view log output (calls to `console.log`) from the app directly in the VS

Congratulations, you've successfully completed this quickstart!
Next, check out the other Azure extensions.
> [!div class="nextstepaction"]
> [Tutorial: Node.js app with MongoDB](app-service-web-tutorial-nodejs-mongodb-app.md)
> [!div class="nextstepaction"]
> [Configure Node.js app](configure-language-nodejs.md)
Check out the other Azure extensions.
* [Cosmos DB](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-cosmosdb)
* [Azure Functions](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions)
Expand All @@ -163,3 +169,4 @@ Next, check out the other Azure extensions.
Or get them all by installing the
[Node Pack for Azure](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-node-azure-pack) extension pack.
3 changes: 3 additions & 0 deletions articles/app-service/app-service-web-get-started-php.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,6 @@ Once deployment has completed, return to the browser window that opened during t

> [!div class="nextstepaction"]
> [PHP with MySQL](app-service-web-tutorial-php-mysql.md)
> [!div class="nextstepaction"]
> [Configure PHP app](configure-language-php.md)
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,8 @@ Advance to the next tutorial to learn how to easily improve the security of your

> [!div class="nextstepaction"]
> [Access SQL Database securely using managed identities for Azure resources](app-service-web-tutorial-connect-msi.md)

More resources:

> [!div class="nextstepaction"]
> [Configure ASP.NET app](configure-language-dotnet-framework.md)
64 changes: 36 additions & 28 deletions articles/app-service/app-service-web-tutorial-dotnetcore-sqldb.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: 'Tutorial: ASP.NET Core with SQL Database'
description: Learn how to get a .NET Core app working in Azure App Service, with connection to SQL Database.
description: Learn how to get a .NET Core app working in Azure App Service, with connection to a SQL Database.

ms.devlang: dotnet
ms.topic: tutorial
ms.date: 04/23/2020
ms.date: 05/27/2020
ms.custom: mvc, cli-validate, seodec18
---

Expand All @@ -14,15 +14,14 @@ ms.custom: mvc, cli-validate, seodec18
> This article deploys an app to App Service on Windows. To deploy to App Service on _Linux_, see [Build a .NET Core and SQL Database app in Azure App Service on Linux](./containers/tutorial-dotnetcore-sqldb-app.md).
>
[App Service](overview.md) provides a highly scalable, self-patching web hosting service in Azure. This tutorial shows how to create a .NET Core app and connect it to SQL Database. When you're done, you'll have a .NET Core MVC app running in App Service.
[App Service](overview.md) provides a highly scalable, self-patching web hosting service in Azure. This tutorial shows how to create a .NET Core app and connect it to a SQL Database. When you're done, you'll have a .NET Core MVC app running in App Service.

![app running in App Service](./media/app-service-web-tutorial-dotnetcore-sqldb/azure-app-in-browser.png)

In this tutorial, you learn how to:

> [!div class="checklist"]
>
> * Create a database in Azure SQL Database
> * Create a SQL Database in Azure
> * Connect a .NET Core app to SQL Database
> * Deploy the app to Azure
> * Update the data model and redeploy the app
Expand Down Expand Up @@ -73,25 +72,28 @@ To stop .NET Core at any time, press `Ctrl+C` in the terminal.

[!INCLUDE [cloud-shell-try-it.md](../../includes/cloud-shell-try-it.md)]

## Create a database in Azure SQL Database
## Create production SQL Database

In this step, you create a SQL Database in Azure. When your app is deployed to Azure, it uses this cloud database.

In this step, you create a database in [Azure SQL Database](/azure/sql-database/). When your app is deployed to Azure, it uses this database.
For SQL Database, this tutorial uses [Azure SQL Database](/azure/sql-database/).

### Create a resource group

[!INCLUDE [Create resource group](../../includes/app-service-web-create-resource-group-no-h.md)]

### Create a server in Azure SQL Database
### Create a SQL Database logical server

In the Cloud Shell, create a SQL Database logical server with the [`az sql server create`](/cli/azure/sql/server?view=azure-cli-latest#az-sql-server-create) command.

In the Cloud Shell, create a [server](../azure-sql/database/logical-servers.md) in Azure SQL Database with the [`az sql server create`](/cli/azure/sql/server?view=azure-cli-latest#az-sql-server-create) command. A server is a logical construct that contains a group of databases managed as a group.
Replace the *\<server-name>* placeholder with a *unique* SQL Database name. This name is used as the part of the globally unique SQL Database endpoint, `<server-name>.database.windows.net`. Valid characters are `a`-`z`, `0`-`9`, `-`. Also, replace *\<db-username>* and *\<db-password>* with a username and password of your choice.

Replace the *\<server-name>* placeholder with a *unique* name. This name is used as the part of the globally unique SQL Database endpoint, `<server-name>.database.windows.net`. Valid characters are `a`-`z`, `0`-`9`, `-`. Also, replace *\<db-username>* and *\<db-password>* with a username and password of your choice.

```azurecli-interactive
az sql server create --name <server-name> --resource-group myResourceGroup --location "West Europe" --admin-user <db-username> --admin-password <db-password>
```

When the server is created, the Azure CLI shows information similar to the following example:
When the SQL Database logical server is created, the Azure CLI shows information similar to the following example:

<pre>
{
Expand All @@ -113,24 +115,25 @@ When the server is created, the Azure CLI shows information similar to the follo

### Configure a server firewall rule

Create a [server-level firewall rule](../azure-sql/database/firewall-configure.md) using the [`az sql server firewall create`](/cli/azure/sql/server/firewall-rule?view=azure-cli-latest#az-sql-server-firewall-rule-create) command. When both starting IP and end IP are set to 0.0.0.0, the firewall is only opened for other Azure resources.
Create an [Azure SQL Database server-level firewall rule](../sql-database/sql-database-firewall-configure.md) using the [`az sql server firewall create`](/cli/azure/sql/server/firewall-rule?view=azure-cli-latest#az-sql-server-firewall-rule-create) command. When both starting IP and end IP are set to 0.0.0.0, the firewall is only opened for other Azure resources.

```azurecli-interactive
az sql server firewall-rule create --resource-group myResourceGroup --server <server-name> --name AllowAzureIps --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0
```

> [!TIP]
> [!TIP]
> You can be even more restrictive in your firewall rule by [using only the outbound IP addresses your app uses](overview-inbound-outbound-ips.md#find-outbound-ips).
>
In the Cloud Shell, run the command again to allow access from your local computer by replacing *\<your-ip-address>* with [your local IPv4 IP address](https://www.whatsmyip.org/).

```azurecli-interactive
az sql server firewall-rule create --name AllowLocalClient --server <server_name> --resource-group myResourceGroup --start-ip-address=<your-ip-address> --end-ip-address=<your-ip-address>
az sql server firewall-rule create --name AllowLocalClient --server <mysql_server_name> --resource-group myResourceGroup --start-ip-address=<your-ip-address> --end-ip-address=<your-ip-address>
```

### Create a database in Azure SQL Database
### Create a database

Create a database with an [S0 performance level](../azure-sql/database/service-tiers-dtu.md) in the server using the [`az sql db create`](/cli/azure/sql/db?view=azure-cli-latest#az-sql-db-create) command.
Create a database with an [S0 performance level](../sql-database/sql-database-service-tiers-dtu.md) in the server using the [`az sql db create`](/cli/azure/sql/db?view=azure-cli-latest#az-sql-db-create) command.

```azurecli-interactive
az sql db create --resource-group myResourceGroup --server <server-name> --name coreDB --service-objective S0
Expand All @@ -141,14 +144,14 @@ az sql db create --resource-group myResourceGroup --server <server-name> --name
Get the connection string using the [`az sql db show-connection-string`](/cli/azure/sql/db?view=azure-cli-latest#az-sql-db-show-connection-string) command.

```azurecli-interactive
az sql db show-connection-string --client ado.net --server <server-name> --name coreDB
az sql db show-connection-string --client ado.net --server cephalin-core --name coreDB
```

In the command output, replace *\<username>*, and *\<password>* with the database administrator credentials you used earlier.

This is the connection string for your .NET Core app. Copy it for use later.

### Configure app to connect to the database in Azure
### Configure app to connect to production database

In your local repository, open Startup.cs and find the following code:

Expand All @@ -166,10 +169,11 @@ services.AddDbContext<MyDatabaseContext>(options =>

> [!IMPORTANT]
> For production apps that need to scale out, follow the best practices in [Applying migrations in production](/aspnet/core/data/ef-rp/migrations#applying-migrations-in-production).
>
### Run database migrations to the database in Azure
### Run database migrations to the production database

Your app currently connects to a local Sqlite database. Now that you configured an Azure SQL Database, recreate the initial migration to target it.
Your app currently connects to a local Sqlite database. Now that you configured an Azure SQL Database, recreate the initial migration to target it.

From the repository root, run the following commands. Replace *\<connection-string>* with the connection string you created earlier.

Expand Down Expand Up @@ -201,7 +205,7 @@ dotnet run

Navigate to `http://localhost:5000` in a browser. Select the **Create New** link and create a couple _to-do_ items. Your app is now reading and writing data to the production database.

Commit your local changes, then commit it into your Git repository.
Commit your local changes, then commit it into your Git repository.

```bash
git add .
Expand All @@ -224,7 +228,7 @@ In this step, you deploy your SQL Database-connected .NET Core application to Ap

### Create a web app

[!INCLUDE [Create web app](../../includes/app-service-web-create-web-app-dotnetcore-win-no-h.md)]
[!INCLUDE [Create web app](../../includes/app-service-web-create-web-app-dotnetcore-win-no-h.md)]

### Configure connection string

Expand All @@ -236,7 +240,7 @@ az webapp config connection-string set --resource-group myResourceGroup --name <

In ASP.NET Core, you can use this named connection string (`MyDbConnection`) using the standard pattern, like any connection string specified in *appsettings.json*. In this case, `MyDbConnection` is also defined in your *appsettings.json*. When running in App Service, the connection string defined in App Service takes precedence over the connection string defined in your *appsettings.json*. The code uses the *appsettings.json* value during local development, and the same code uses the App Service value when deployed.

To see how the connection string is referenced in your code, see [Configure app to connect to production database](#configure-app-to-connect-to-the-database-in-azure).
To see how the connection string is referenced in your code, see [Configure app to connect to production database](#configure-app-to-connect-to-production-database).

### Push to Azure from Git

Expand Down Expand Up @@ -380,8 +384,8 @@ While the ASP.NET Core app runs in Azure App Service, you can get the console lo

The sample project already follows the guidance at [ASP.NET Core Logging in Azure](https://docs.microsoft.com/aspnet/core/fundamentals/logging#azure-app-service-provider) with two configuration changes:
* Includes a reference to `Microsoft.Extensions.Logging.AzureAppServices` in *DotNetCoreSqlDb.csproj*.
* Calls `loggerFactory.AddAzureWebAppDiagnostics()` in *Program.cs*.
- Includes a reference to `Microsoft.Extensions.Logging.AzureAppServices` in *DotNetCoreSqlDb.csproj*.
- Calls `loggerFactory.AddAzureWebAppDiagnostics()` in *Program.cs*.

To set the ASP.NET Core [log level](https://docs.microsoft.com/aspnet/core/fundamentals/logging#log-level) in App Service to `Information` from the default level `Error`, use the [`az webapp log config`](/cli/azure/webapp/log?view=azure-cli-latest#az-webapp-log-config) command in the Cloud Shell.
Expand All @@ -391,6 +395,7 @@ az webapp log config --name <app-name> --resource-group myResourceGroup --applic

> [!NOTE]
> The project's log level is already set to `Information` in *appsettings.json*.
>

To start log streaming, use the [`az webapp log tail`](/cli/azure/webapp/log?view=azure-cli-latest#az-webapp-log-tail) command in the Cloud Shell.

Expand Down Expand Up @@ -421,14 +426,12 @@ By default, the portal shows your app's **Overview** page. This page gives you a
[!INCLUDE [cli-samples-clean-up](../../includes/cli-samples-clean-up.md)]

<a name="next"></a>

## Next steps

What you learned:

> [!div class="checklist"]
>
> * Create a database in Azure SQL Database
> * Create a SQL Database in Azure
> * Connect a .NET Core app to SQL Database
> * Deploy the app to Azure
> * Update the data model and redeploy the app
Expand All @@ -439,3 +442,8 @@ Advance to the next tutorial to learn how to map a custom DNS name to your app.

> [!div class="nextstepaction"]
> [Tutorial: Map custom DNS name to your app](app-service-web-tutorial-custom-domain.md)

More resources:

> [!div class="nextstepaction"]
> [Configure ASP.NET Core app](configure-language-dotnetcore.md)
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,8 @@ Advance to the next tutorial to learn how to map a custom DNS name to the app.

> [!div class="nextstepaction"]
> [Map an existing custom DNS name to Azure App Service](app-service-web-tutorial-custom-domain.md)
More resources:

> [!div class="nextstepaction"]
> [Configure Node.js app](configure-language-nodejs.md)
5 changes: 5 additions & 0 deletions articles/app-service/app-service-web-tutorial-php-mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,8 @@ Advance to the next tutorial to learn how to map a custom DNS name to the app.

> [!div class="nextstepaction"]
> [Map an existing custom DNS name to Azure App Service](app-service-web-tutorial-custom-domain.md)
More resources:

> [!div class="nextstepaction"]
> [Configure PHP app](configure-language-php.md)
Loading

0 comments on commit 6f5310b

Please sign in to comment.