Tutorial: Build a PHP and MySQL app in Azure App Service
Azure App Service provides a highly scalable, self-patching web hosting service using the Windows operating system. This tutorial shows how to create a PHP app in Azure and connect it to a MySQL database. When you're finished, you'll have a Laravel app running on Azure App Service on Windows.
Azure App Service provides a highly scalable, self-patching web hosting service using the Linux operating system. This tutorial shows how to create a PHP app in Azure and connect it to a MySQL database. When you're finished, you'll have a Laravel app running on Azure App Service on Linux.
In this tutorial, you learn how to:
- Create a MySQL database in Azure
- Connect a PHP app to MySQL
- Deploy the app to Azure
- Update the data model and redeploy the app
- Stream diagnostic logs from Azure
- Manage the app in the Azure portal
If you don't have an Azure subscription, create an Azure free account before you begin.s
Prerequisites
To complete this tutorial:
- Install Git
- Install PHP 5.6.4 or above
- Install Composer
- Enable the following PHP extensions Laravel needs: OpenSSL, PDO-MySQL, Mbstring, Tokenizer, XML
- Install and start MySQL
Use the Bash environment in Azure Cloud Shell. For more information, see Azure Cloud Shell Quickstart - Bash.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you are running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For additional sign-in options, see Sign in with the Azure CLI.
When you're prompted, install Azure CLI extensions on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
Prepare local MySQL
In this step, you create a database in your local MySQL server for your use in this tutorial.
Connect to local MySQL server
In a terminal window, connect to your local MySQL server. You can use this terminal window to run all the commands in this tutorial.
mysql -u root -p
If you're prompted for a password, enter the password for the root account. If you don't remember your root account password, see MySQL: How to Reset the Root Password.
If your command runs successfully, then your MySQL server is running. If not, ensure that your local MySQL server is started by following the MySQL post-installation steps.
Create a database locally
At the
mysqlprompt, create a database.CREATE DATABASE sampledb;Exit your server connection by typing
quit.quit
Create a PHP app locally
In this step, you get a Laravel sample application, configure its database connection, and run it locally.
Clone the sample
In the terminal window, cd to a working directory.
Clone the sample repository and change to the repository root.
git clone https://github.com/Azure-Samples/laravel-tasks cd laravel-tasksEnsure the default branch is
main.git branch -m mainTip
The branch name change isn't required by App Service. But, since many repositories are changing their default branch to
main, this tutorial also shows you how to deploy a repository frommain. For more information, see Change deployment branch.Install the required packages.
composer install
Configure MySQL connection
In the repository root, create a file named .env. Copy the following variables into the .env file. Replace the <root_password> placeholder with the MySQL root user's password.
APP_ENV=local
APP_DEBUG=true
APP_KEY=
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=sampledb
DB_USERNAME=root
DB_PASSWORD=<root_password>
For information on how Laravel uses the .env file, see Laravel Environment Configuration.
Run the sample locally
Run Laravel database migrations to create the tables the application needs. To see which tables are created in the migrations, look in the database/migrations directory in the Git repository.
php artisan migrateGenerate a new Laravel application key.
php artisan key:generateRun the application.
php artisan serveGo to
http://localhost:8000in a browser. Add a few tasks in the page.
To stop PHP, enter
Ctrl + Cin the terminal.
Create MySQL in Azure
In this step, you create a MySQL database in Azure Database for MySQL. Later, you set up the PHP application to connect to this database.
Create a resource group
A resource group is a logical container into which Azure resources, such as web apps, databases, and storage accounts, are deployed and managed. For example, you can choose to delete the entire resource group in one simple step later.
In the Cloud Shell, create a resource group with the az group create command. The following example creates a resource group named myResourceGroup in the West Europe location. To see all supported locations for App Service in Free tier, run the az appservice list-locations --sku FREE command.
az group create --name myResourceGroup --location "West Europe"
You generally create your resource group and the resources in a region near you.
When the command finishes, a JSON output shows you the resource group properties.
Create a MySQL server
In the Cloud Shell, create a server in Azure Database for MySQL with the az mysql server create command.
In the following command, substitute a unique server name for the <mysql-server-name> placeholder, a user name for the <admin-user>, and a password for the <admin-password> placeholder. The server name is used as part of your MySQL endpoint (https://<mysql-server-name>.mysql.database.azure.com), so the name needs to be unique across all servers in Azure. For details on selecting MySQL DB SKU, see Create an Azure Database for MySQL server.
az mysql server create --resource-group myResourceGroup --name <mysql-server-name> --location "West Europe" --admin-user <admin-user> --admin-password <admin-password> --sku-name B_Gen5_1
When the MySQL server is created, the Azure CLI shows information similar to the following example:
{
"administratorLogin": "<admin-user>",
"administratorLoginPassword": null,
"fullyQualifiedDomainName": "<mysql-server-name>.mysql.database.azure.com",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DBforMySQL/servers/<mysql-server-name>",
"location": "westeurope",
"name": "<mysql-server-name>",
"resourceGroup": "myResourceGroup",
...
- < Output has been truncated for readability >
}
Configure server firewall
In the Cloud Shell, create a firewall rule for your MySQL server to allow client connections by using the
az mysql server firewall-rule createcommand. When both starting IP and end IP are set to 0.0.0.0, the firewall is only opened for other Azure resources.az mysql server firewall-rule create --name allAzureIPs --server <mysql-server-name> --resource-group myResourceGroup --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0Tip
You can be even more restrictive in your firewall rule by using only the outbound IP addresses your app uses.
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.
az mysql 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 production database
In the local terminal window, connect to the MySQL server in Azure. Use the value you specified previously for <admin-user> and <mysql-server-name>. When prompted for a password, use the password you specified when you created the database in Azure.
mysql -u <admin-user>@<mysql-server-name> -h <mysql-server-name>.mysql.database.azure.com -P 3306 -pAt the
mysqlprompt, create a database.CREATE DATABASE sampledb;Create a database user called phpappuser and give it all privileges in the
sampledbdatabase. For simplicity of the tutorial, use MySQLAzure2017 as the password.CREATE USER 'phpappuser' IDENTIFIED BY 'MySQLAzure2017'; GRANT ALL PRIVILEGES ON sampledb.* TO 'phpappuser';Exit the server connection by entering
quit.quit
Connect app to Azure MySQL
In this step, you connect the PHP application to the MySQL database you created in Azure Database for MySQL.
Configure the database connection
In the repository root, create an .env.production file and copy the following variables into it. Replace the placeholder_<mysql-server-name>_ in both DB_HOST and DB_USERNAME.
APP_ENV=production
APP_DEBUG=true
APP_KEY=
DB_CONNECTION=mysql
DB_HOST=<mysql-server-name>.mysql.database.azure.com
DB_DATABASE=sampledb
DB_USERNAME=phpappuser@<mysql-server-name>
DB_PASSWORD=MySQLAzure2017
MYSQL_SSL=true
Save the changes.
Tip
To secure your MySQL connection information, this file is already excluded from the Git repository (See .gitignore in the repository root). Later, you learn how to set up the environment variables in App Service to connect to your database in Azure Database for MySQL. With environment variables, you don't need the .env file in App Service.
Configure TLS/SSL certificate
By default, Azure Database for MySQL enforces TLS connections from clients. To connect to your MySQL database in Azure, you must use the .pem certificate supplied by Azure Database for MySQL.
Open config/database.php and add the sslmode and options parameters to connections.mysql, as shown in the following code.
'mysql' => [
...
'sslmode' => env('DB_SSLMODE', 'prefer'),
'options' => (env('MYSQL_SSL')) ? [
PDO::MYSQL_ATTR_SSL_KEY => '/ssl/BaltimoreCyberTrustRoot.crt.pem',
] : []
],
'mysql' => [
...
'sslmode' => env('DB_SSLMODE', 'prefer'),
'options' => (env('MYSQL_SSL') && extension_loaded('pdo_mysql')) ? [
PDO::MYSQL_ATTR_SSL_KEY => '/ssl/BaltimoreCyberTrustRoot.crt.pem',
] : []
],
The certificate BaltimoreCyberTrustRoot.crt.pem is provided in the repository for convenience in this tutorial.
Test the application locally
Run Laravel database migrations with .env.production as the environment file to create the tables in your MySQL database in Azure Database for MySQL. Remember that .env.production has the connection information to your MySQL database in Azure.
php artisan migrate --env=production --force.env.production doesn't have a valid application key yet. Generate a new one for it in the terminal.
php artisan key:generate --env=production --forceRun the sample application with .env.production as the environment file.
php artisan serve --env=productionGo to
http://localhost:8000. If the page loads without errors, the PHP application is connecting to the MySQL database in Azure.Add a few tasks in the page.

To stop PHP, enter
Ctrl + Cin the terminal.
Commit your changes
Run the following Git commands to commit your changes:
git add .
git commit -m "database.php updates"
Your app is ready to be deployed.
Deploy to Azure
In this step, you deploy the MySQL-connected PHP application to Azure App Service.
Configure a deployment user
FTP and local Git can deploy to an Azure web app by using a deployment user. Once you configure your deployment user, you can use it for all your Azure deployments. Your account-level deployment username and password are different from your Azure subscription credentials.
To configure the deployment user, run the az webapp deployment user set command in Azure Cloud Shell. Replace <username> and <password> with a deployment user username and password.
- The username must be unique within Azure, and for local Git pushes, must not contain the ‘@’ symbol.
- The password must be at least eight characters long, with two of the following three elements: letters, numbers, and symbols.
az webapp deployment user set --user-name <username> --password <password>
The JSON output shows the password as null. If you get a 'Conflict'. Details: 409 error, change the username. If you get a 'Bad Request'. Details: 400 error, use a stronger password.
Record your username and password to use to deploy your web apps.
Create an App Service plan
In the Cloud Shell, create an App Service plan with the az appservice plan create command.
The following example creates an App Service plan named myAppServicePlan in the Free pricing tier:
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku FREE
When the App Service plan has been created, the Azure CLI shows information similar to the following example:
{
"adminSiteName": null,
"appServicePlanName": "myAppServicePlan",
"geoRegion": "West Europe",
"hostingEnvironmentProfile": null,
"id": "/subscriptions/0000-0000/resourceGroups/myResourceGroup/providers/Microsoft.Web/serverfarms/myAppServicePlan",
"kind": "app",
"location": "West Europe",
"maximumNumberOfWorkers": 1,
"name": "myAppServicePlan",
< JSON data removed for brevity. >
"targetWorkerSizeId": 0,
"type": "Microsoft.Web/serverfarms",
"workerTierName": null
}
In the Cloud Shell, create an App Service plan with the az appservice plan create command.
The following example creates an App Service plan named myAppServicePlan in the Free pricing tier:
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku FREE --is-linux
When the App Service plan has been created, the Azure CLI shows information similar to the following example:
{
"freeOfferExpirationTime": null,
"geoRegion": "West Europe",
"hostingEnvironmentProfile": null,
"id": "/subscriptions/0000-0000/resourceGroups/myResourceGroup/providers/Microsoft.Web/serverfarms/myAppServicePlan",
"kind": "linux",
"location": "West Europe",
"maximumNumberOfWorkers": 1,
"name": "myAppServicePlan",
< JSON data removed for brevity. >
"targetWorkerSizeId": 0,
"type": "Microsoft.Web/serverfarms",
"workerTierName": null
}
Create a web app
Create a web app in the myAppServicePlan App Service plan.
In the Cloud Shell, you can use the az webapp create command. In the following example, replace <app-name> with a globally unique app name (valid characters are a-z, 0-9, and -). The runtime is set to PHP|7.2. To see all supported runtimes, run az webapp list-runtimes --os linux.
# Bash
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app-name> --runtime "PHP|7.2" --deployment-local-git
# PowerShell
az --% webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app-name> --runtime "PHP|7.2" --deployment-local-git
When the web app has been created, the Azure CLI shows output similar to the following example:
Local git is configured with url of 'https://<username>@<app-name>.scm.azurewebsites.net/<app-name>.git'
{
"availabilityState": "Normal",
"clientAffinityEnabled": true,
"clientCertEnabled": false,
"cloningInfo": null,
"containerSize": 0,
"dailyMemoryTimeQuota": 0,
"defaultHostName": "<app-name>.azurewebsites.net",
"deploymentLocalGitUrl": "https://<username>@<app-name>.scm.azurewebsites.net/<app-name>.git",
"enabled": true,
< JSON data removed for brevity. >
}
You’ve created an empty new web app, with git deployment enabled.
Note
The URL of the Git remote is shown in the deploymentLocalGitUrl property, with the format https://<username>@<app-name>.scm.azurewebsites.net/<app-name>.git. Save this URL as you need it later.
Create a web app in the myAppServicePlan App Service plan.
In the Cloud Shell, you can use the az webapp create command. In the following example, replace <app-name> with a globally unique app name (valid characters are a-z, 0-9, and -). The runtime is set to PHP|7.2. To see all supported runtimes, run az webapp list-runtimes --os linux.
# Bash
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app-name> --runtime "PHP|7.2" --deployment-local-git
# PowerShell
az --% webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app-name> --runtime "PHP|7.2" --deployment-local-git
When the web app has been created, the Azure CLI shows output similar to the following example:
Local git is configured with url of 'https://<username>@<app-name>.scm.azurewebsites.net/<app-name>.git'
{
"availabilityState": "Normal",
"clientAffinityEnabled": true,
"clientCertEnabled": false,
"cloningInfo": null,
"containerSize": 0,
"dailyMemoryTimeQuota": 0,
"defaultHostName": "<app-name>.azurewebsites.net",
"deploymentLocalGitUrl": "https://<username>@<app-name>.scm.azurewebsites.net/<app-name>.git",
"enabled": true,
< JSON data removed for brevity. >
}
You’ve created an empty new web app, with git deployment enabled.
Note
The URL of the Git remote is shown in the deploymentLocalGitUrl property, with the format https://<username>@<app-name>.scm.azurewebsites.net/<app-name>.git. Save this URL as you need it later.
Configure database settings
In App Service, you set environment variables as app settings by using the az webapp config appsettings set command.
The following command configures the app settings DB_HOST, DB_DATABASE, DB_USERNAME, and DB_PASSWORD. Replace the placeholders <app-name> and <mysql-server-name>.
az webapp config appsettings set --name <app-name> --resource-group myResourceGroup --settings DB_HOST="<mysql-server-name>.mysql.database.azure.com" DB_DATABASE="sampledb" DB_USERNAME="phpappuser@<mysql-server-name>" DB_PASSWORD="MySQLAzure2017" MYSQL_SSL="true"
You can use the PHP getenv method to access the settings. the Laravel code uses an env wrapper over the PHP getenv. For example, the MySQL configuration in config/database.php looks like the following code:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
...
],
Configure Laravel environment variables
Laravel needs an application key in App Service. You can configure it with app settings.
In the local terminal window, use
php artisanto generate a new application key without saving it to .env.php artisan key:generate --showIn the Cloud Shell, set the application key in the App Service app by using the
az webapp config appsettings setcommand. Replace the placeholders <app-name> and <outputofphpartisankey:generate>.az webapp config appsettings set --name <app-name> --resource-group myResourceGroup --settings APP_KEY="<output_of_php_artisan_key:generate>" APP_DEBUG="true"APP_DEBUG="true"tells Laravel to return debugging information when the deployed app encounters errors. When running a production application, set it tofalse, which is more secure.
Set the virtual application path
Set the virtual application path for the app. This step is required because the Laravel application lifecycle begins in the public directory instead of the application's root directory. Other PHP frameworks whose lifecycle start in the root directory can work without manual configuration of the virtual application path.
In the Cloud Shell, set the virtual application path by using the az resource update command. Replace the <app-name> placeholder.
az resource update --name web --resource-group myResourceGroup --namespace Microsoft.Web --resource-type config --parent sites/<app_name> --set properties.virtualApplications[0].physicalPath="site\wwwroot\public" --api-version 2015-06-01
By default, Azure App Service points the root virtual application path (/) to the root directory of the deployed application files (sites\wwwroot).
Laravel application lifecycle begins in the public directory instead of the application's root directory. The default PHP Docker image for App Service uses Apache, and it doesn't let you customize the DocumentRoot for Laravel. But you can use .htaccess to rewrite all requests to point to /public instead of the root directory. In the repository root, an .htaccess is added already for this purpose. With it, your Laravel application is ready to be deployed.
For more information, see Change site root.
Push to Azure from Git
Since you're deploying the
mainbranch, you need to set the default deployment branch for your App Service app tomain(see Change deployment branch). In the Cloud Shell, set theDEPLOYMENT_BRANCHapp setting with theaz webapp config appsettings setcommand.az webapp config appsettings set --name <app-name> --resource-group myResourceGroup --settings DEPLOYMENT_BRANCH='main'Back in the local terminal window, add an Azure remote to your local Git repository. Replace <deploymentLocalGitUrl-from-create-step> with the URL of the Git remote that you saved from Create a web app.
git remote add azure <deploymentLocalGitUrl-from-create-step>Push to the Azure remote to deploy your app with the following command. When Git Credential Manager prompts you for credentials, make sure you enter the credentials you created in Configure a deployment user, not the credentials you use to sign in to the Azure portal.
git push azure mainThis command may take a few minutes to run. While running, it displays information similar to the following example:
Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 291 bytes | 0 bytes/s, done. Total 3 (delta 2), reused 0 (delta 0) remote: Updating branch 'main'. remote: Updating submodules. remote: Preparing deployment for commit id 'a5e076db9c'. remote: Running custom deployment command... remote: Running deployment command... ... < Output has been truncated for readability >
Note
You may notice that the deployment process installs Composer packages at the end. App Service does not run these automations during default deployment, so this sample repository has three additional files in its root directory to enable it:
.deployment- This file tells App Service to runbash deploy.shas the custom deployment script.deploy.sh- The custom deployment script. If you review the file, you will see that it runsphp composer.phar installafternpm install.composer.phar- The Composer package manager.
You can use this approach to add any step to your Git-based deployment to App Service. For more information, see Custom Deployment Script.
Since you're deploying the
mainbranch, you need to set the default deployment branch for your App Service app tomain(see Change deployment branch). In the Cloud Shell, set theDEPLOYMENT_BRANCHapp setting with theaz webapp config appsettings setcommand.az webapp config appsettings set --name <app-name> --resource-group myResourceGroup --settings DEPLOYMENT_BRANCH='main'Back in the local terminal window, add an Azure remote to your local Git repository. Replace <deploymentLocalGitUrl-from-create-step> with the URL of the Git remote that you saved from Create a web app.
git remote add azure <deploymentLocalGitUrl-from-create-step>Push to the Azure remote to deploy your app with the following command. When Git Credential Manager prompts you for credentials, make sure you enter the credentials you created in Configure a deployment user, not the credentials you use to sign in to the Azure portal.
git push azure mainThis command may take a few minutes to run. While running, it displays information similar to the following example:
Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 291 bytes | 0 bytes/s, done. Total 3 (delta 2), reused 0 (delta 0) remote: Updating branch 'main'. remote: Updating submodules. remote: Preparing deployment for commit id 'a5e076db9c'. remote: Running custom deployment command... remote: Running deployment command... ... < Output has been truncated for readability >
Browse to the Azure app
Browse to http://<app-name>.azurewebsites.net and add a few tasks to the list.
Congratulations, you're running a data-driven PHP app in Azure App Service.
Update model locally and redeploy
In this step, you make a simple change to the task data model and the webapp, and then publish the update to Azure.
For the tasks scenario, you change the application so that you can mark a task as complete.
Add a column
In the local terminal window, go to the root of the Git repository.
Generate a new database migration for the
taskstable:php artisan make:migration add_complete_column --table=tasksThis command shows you the name of the migration file that's generated. Find this file in database/migrations and open it.
Replace the
upmethod with the following code:public function up() { Schema::table('tasks', function (Blueprint $table) { $table->boolean('complete')->default(False); }); }The preceding code adds a boolean column in the
taskstable calledcomplete.Replace the
downmethod with the following code for the rollback action:public function down() { Schema::table('tasks', function (Blueprint $table) { $table->dropColumn('complete'); }); }In the local terminal window, run Laravel database migrations to make the change in the local database.
php artisan migrateBased on the Laravel naming convention, the model
Task(see app/Task.php) maps to thetaskstable by default.
Update application logic
Open the routes/web.php file. The application defines its routes and business logic here.
At the end of the file, add a route with the following code:
/** * Toggle Task completeness */ Route::post('/task/{id}', function ($id) { error_log('INFO: post /task/'.$id); $task = Task::findOrFail($id); $task->complete = !$task->complete; $task->save(); return redirect('/'); });The preceding code makes a simple update to the data model by toggling the value of
complete.
Update the view
Open the resources/views/tasks.blade.php file. Find the
<tr>opening tag and replace it with:<tr class="{{ $task->complete ? 'success' : 'active' }}" >The preceding code changes the row color depending on whether the task is complete.
In the next line, you have the following code:
<td class="table-text"><div>{{ $task->name }}</div></td>Replace the entire line with the following code:
<td> <form action="{{ url('task/'.$task->id) }}" method="POST"> {{ csrf_field() }} <button type="submit" class="btn btn-xs"> <i class="fa {{$task->complete ? 'fa-check-square-o' : 'fa-square-o'}}"></i> </button> {{ $task->name }} </form> </td>The preceding code adds the submit button that references the route that you defined earlier.
Test the changes locally
In the local terminal window, run the development server from the root directory of the Git repository.
php artisan serveTo see the task status change, go to
http://localhost:8000and select the checkbox.
To stop PHP, enter
Ctrl + Cin the terminal.
Publish changes to Azure
In the local terminal window, run Laravel database migrations with the production connection string to make the change in the Azure database.
php artisan migrate --env=production --forceCommit all the changes in Git, and then push the code changes to Azure.
git add . git commit -m "added complete checkbox" git push azure mainOnce the
git pushis complete, go to the Azure app and test the new functionality.
If you add any task, they're retained in the database. Updates to the data schema leave existing data intact.
Stream diagnostic logs
While the PHP application runs in Azure App Service, you can get the console logs piped to your terminal. That way, you can get the same diagnostic messages to help you debug application errors.
To start log streaming, use the az webapp log tail command in the Cloud Shell.
az webapp log tail --name <app_name> --resource-group myResourceGroup
Once log streaming has started, refresh the Azure app in the browser to get some web traffic. You can now see console logs piped to the terminal. If you don't see console logs immediately, check again in 30 seconds.
To stop log streaming at any time, enter Ctrl+C.
To access the console logs generated from inside your application code in App Service, turn on diagnostics logging by running the following command in the Cloud Shell:
az webapp log config --resource-group <resource-group-name> --name <app-name> --docker-container-logging filesystem --level Verbose
Possible values for --level are: Error, Warning, Info, and Verbose. Each subsequent level includes the previous level. For example: Error includes only error messages, and Verbose includes all messages.
Once diagnostic logging is turned on, run the following command to see the log stream:
az webapp log tail --resource-group <resource-group-name> --name <app-name>
If you don't see console logs immediately, check again in 30 seconds.
Note
You can also inspect the log files from the browser at https://<app-name>.scm.azurewebsites.net/api/logs/docker.
To stop log streaming at any time, type Ctrl+C.
Tip
A PHP application can use the standard error_log() to output to the console. The sample application uses this approach in app/Http/routes.php.
As a web framework, Laravel uses Monolog as the logging provider. To see how to get Monolog to output messages to the console, see PHP: How to use monolog to log to console (php://out).
Manage the Azure app
Go to the Azure portal to manage the app you created.
From the left menu, select App Services, and then select the name of your Azure app.

You see your app's Overview page. In this page, you can do basic management tasks like stop, start, restart, browse, and delete.
The left menu provides pages for configuring your app.

Clean up resources
In the preceding steps, you created Azure resources in a resource group. If you don't expect to need these resources in the future, delete the resource group by running the following command in the Cloud Shell:
az group delete --name myResourceGroup
This command may take a minute to run.
Next steps
In this tutorial, you learned how to:
- Create a MySQL database in Azure
- Connect a PHP app to MySQL
- Deploy the app to Azure
- Update the data model and redeploy the app
- Stream diagnostic logs from Azure
- Manage the app in the Azure portal
Advance to the next tutorial to learn how to map a custom DNS name to the app.
Or, check out other resources:
Povratne informacije
Pošalјite i prikažite povratne informacije za
