You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Tutorial: Deploy a PHP, MySQL, and Redis app to Azure App Service
14
14
15
-
This tutorial shows how to create a secure PHP app in Azure App Service that's connected to a MySQL database (using Azure Database for MySQL Flexible Server). You'll also deploy an Azure Cache for Redis to enable the caching code in your application. Azure App Service is a highly scalable, self-patching, web-hosting service that can easily deploy apps on Windows or Linux. When you're finished, you'll have a Laravel app running on Azure App Service on Linux.
15
+
This tutorial shows how to create a secure PHP app in Azure App Service connects to a MySQL database (using Azure Database for MySQL Flexible Server). You'll also deploy an Azure Cache for Redis to enable the caching code in your application. Azure App Service is a highly scalable, self-patching, web-hosting service that can easily deploy apps on Windows or Linux. When you're finished, you'll have a Laravel app running on Azure App Service on Linux.
16
16
17
17
:::image type="content" source="./media/tutorial-php-mysql-app/azure-portal-browse-app-2.png" alt-text="Screenshot of the Azure app example titled Task List showing new tasks added.":::
18
18
@@ -540,31 +540,33 @@ In this step, you create the Azure resources and deploy a sample app to App Serv
540
540
541
541
The GitHub codespace already has the [Azure Developer CLI](/azure/developer/azure-developer-cli/install-azd) (AZD).
542
542
543
+
1. Generate a Laravel encryption key with `php artisan key:generate --show`:
544
+
545
+
```bash
546
+
php artisan key:generate --show
547
+
```
548
+
543
549
1. Sign into Azure by running the `azd auth login`command and following the prompt:
544
550
545
551
```bash
546
552
azd auth login
547
553
```
548
554
549
-
1. From the repository root, run `azd init`.
555
+
1. Create the necessary Azure resources and deploy the app code with the `azd up` command. Follow the prompt to selectthe desired subscription and location for the Azure resources.
|The current directory is not empty. Would you like to initialize a project here in'\<your-directory>'?|**Y**|
560
-
|What would you like to do with these files?|**Keep my existing files unchanged**|
561
565
|Enter a new environment name | Type a unique name. The AZD template uses this name as part of the DNS name of your web app in Azure (`<app-name>-<hash>.azurewebsites.net`). Alphanumeric characters and hyphens are allowed. |
562
-
563
-
1. Create the necessary Azure resources and deploy the app code with the `azd up` command. Follow the prompt to selectthe desired subscription and location for the Azure resources.
564
-
565
-
```bash
566
-
azd up
567
-
```
566
+
|Select an Azure Subscription to use| Select your subscription. |
567
+
|Select an Azure location to use| Select a location. |
568
+
|Enter a value forthe 'appKey' infrastructure secured parameter| Use the output of `php artisan key:generate --show` here. The AZD template creates a Key Vault secret for it that you can usein your app. |
569
+
|Enter a value for the 'databasePassword' infrastructure secured parameter| Database password for MySQL. It must be at least 8 characters long and contain uppercase letters, lowercase letters, numbers, and special characters.|
568
570
569
571
The `azd up`command takes about 15 minutes to complete (the Redis cache takes the most time). It also compiles and deploys your application code, but you modify your code later to work with App Service. While it's running, the command provides messages about the provisioning and deployment process, including a link to the deployment in Azure. When it finishes, the command also displays a link to the deploy application.
570
572
@@ -581,8 +583,6 @@ The GitHub codespace already has the [Azure Developer CLI](/azure/developer/azur
581
583
- **Log Analytics workspace**: Acts as the target container for your app to ship its logs, where you can also query the logs.
582
584
- **Key vault**: Used to keep your database password the same when you redeploy with AZD.
583
585
584
-
Once the command finishes creating resources and deploying the application code the first time, the deployed sample app doesn't work yet because you must make small changes to make it connect to the database in Azure.
585
-
586
586
Having issues? Check the [Troubleshooting section](#troubleshooting).
587
587
588
588
## 3. Use Azure connection strings in application code
@@ -707,9 +707,7 @@ With the MySQL database protected by the virtual network, the easiest way to run
707
707
php artisan migrate --force
708
708
```
709
709
710
-
If it succeeds, App Service is [connecting successfully to the database](#i-get-an-error-when-running-database-migrations).
711
-
712
-
:::image type="content" source="./media/tutorial-php-mysql-app/azure-portal-check-config-in-ssh-2.png" alt-text="A screenshot showing the commands to run in the SSH shell and their output.":::
710
+
If it succeeds, App Service is [connecting successfully to the database](#i-get-the-error-during-database-migrations-php_network_getaddresses-getaddrinfo-for-mysqldb-failed-no-address-associated-with-hostname).
713
711
714
712
> [!NOTE]
715
713
> Only changes to files in `/home` can persist beyond app restarts.
@@ -768,6 +766,10 @@ azd down
768
766
769
767
It indicates that MySQL connection variables are not properly configured. Verify that the `AZURE_MYSQL_` app settings are properly configured in [3. Use Azure connection strings in application code](#3-use-azure-connection-strings-in-application-code).
770
768
769
+
#### I get a blank page in the browser.
770
+
771
+
It indicates that App Service can't find the PHP start files in*/public*. Follow the steps in [4. Configure Laravel settings in web app](#4-configure-laravel-settings-in-web-app).
772
+
771
773
#### I get a debug page in the browser saying `Unsupported cipher or incorrect key length.`
772
774
773
775
It indicates that the `APP_KEY` setting is set to an invalid key. When you run `azd up`, make sure you set`appKey` to the output of `php artisan key:generate --show`.
0 commit comments