Deploy web static files
Azure Spring Apps is the new name for the Azure Spring Cloud service. Although the service has a new name, you'll see the old name in some places for a while as we work to update assets such as screenshots, videos, and diagrams.
This article applies to: ❌ Basic/Standard ✔️ Enterprise
- An already provisioned Azure Spring Apps Enterprise plan instance. For more information, see Quickstart: Build and deploy apps to Azure Spring Apps using the Enterprise plan.
- One or more applications running in Azure Spring Apps. For more information on creating apps, see How to Deploy Spring Boot applications from Azure CLI.
- Azure CLI, version 2.45.0 or higher.
- Your static files or dynamic front-end application - for example, a React app.
Deploy your static files
You can deploy static files to Azure Spring Apps using NGINX or HTTPD web servers in the following ways:
- You can deploy static files directly. Azure Spring Apps automatically configures the specified web server to serve the static files.
You can also create a server configuration file to customize the web server.
Deploy static files directly
Use the following command to deploy static files directly using an autogenerated default server configuration file.
az spring app deploy --resource-group <your-resource-group-name> \ --service <your-Azure-Spring-Apps-name> \ --name <your-app-name> \ --source-path <path-to-source-code> \ --build-env BP_WEB_SERVER=nginx
For more information, see the Configure an autogenerated server configuration file section of this article.
Deploy your front-end application as static content
Use the following command to deploy a dynamic front-end application from source code.
az spring app deploy --resource-group <your-resource-group-name> \ --service <your-Azure-Spring-Apps-name> \ --name <your-app-name> \ --source-path <path-to-source-code> \ --build-env BP_WEB_SERVER=nginx BP_NODE_RUN_SCRIPTS=build BP_WEB_SERVER_ROOT=build
Deploy static files using a customized configuration file
Use the following command to deploy static files using a customized server configuration file.
az spring app deploy --resource-group <your-resource-group-name> \ --service <your-Azure-Spring-Apps-name> \ --name <your-app-name> \ --source-path <path-to-source-code>
For more information, see the Using a customized server configuration file section of this article.
The sample code is maintained by the Paketo open source community.
The Paketo buildpacks samples demonstrate common use cases for several different application types, including the following use cases:
- Serving static files with a default server configuration file using
BP_WEB_SERVERto select either HTTPD or NGINX.
- Using Node Package Manager to build a React app into static files that a web server can serve. Use the following steps:
- Define a script under the
scriptsproperty of the package.json file that builds your production-ready static assets. For React, it's
- Find out where static assets are stored after the build script runs. For React, static assets are stored in
BP_NODE_RUN_SCRIPTSto the name of the build script.
BP_WEB_SERVER_ROOTto the build output directory.
- Define a script under the
- Serving static files with your own server configuration file, using either HTTPD or NGINX.
Configure an autogenerated server configuration file
You can use environment variables to modify the autogenerated server configuration file. The following table shows supported environment variables.
|Environment Variable||Supported Value||Description|
||nginx or httpd||Specifies the web server type, either nginx for Nginx or httpd for Apache HTTP server. Required when using the autogenerated server configuration file.|
||An absolute file path or a file path relative to /workspace.||Sets the root directory for the static files. The default is
||true or false||Enables push state routing for your application. Regardless of the route that is requested, index.html is always served. Useful for single-page web applications.|
||true or false||Enforces HTTPS for server connections by redirecting all requests to use the HTTPS protocol.|
The following environment variables aren't supported.
Using a customized server configuration file
You can configure web server by using a customized server configuration file. Your configuration file must conform to the restrictions described in the following table.
|Configuration||Description||Nginx Configuration||Httpd Configuration|
|Listening port||Web server must listen on port 8080. The service checks the port on TCP for readiness and whether it's live. You must use the templated variable
|Log path||Config log path to the console.||
|File path with write permission||Web server is granted write permission to the /tmp directory. Configuring the full path requires write permission under the /tmp directory.||For example: client_body_temp_path /tmp/client_body_temp|
|Maximum accepted body size of client request||Web server is behind the gateway. The maximum accepted body size of the client request is set to 500 m in the gateway and the value for web server must be less than 500 m.||
Deploying static files to the Azure Spring Apps Enterprise plan supports the Dynatrace buildpack binding. The
htpasswd buildpack binding isn't supported.
For more information, see How to configure APM integration and CA certificates.
Common build and deployment errors
Your deployment of static files to the Azure Spring Apps Enterprise plan may generate the following common build errors:
ERROR: No buildpack groups passed detection.
ERROR: Please check that you're running against the correct path.
ERROR: failed to detect: no buildpacks participating
The root cause of these errors is that the web server type isn't specified. To resolve these errors, set the environment variable
BP_WEB_SERVER to nginx or httpd.
The following table describes common deployment errors when you deploy static files to the Azure Spring Apps Enterprise plan.
|Error message||Root cause||Solution|
||The web server failed to start.||Validate your server configuration file to see if there's a configuration error. Then, check whether your configuration file conforms to the restrictions described in the Using a customized server configuration file section.|
||The web server doesn't have write permission to the specified path.||Configure the path under the directory /tmp; for example: /tmp/client_body_temp.|
Submit and view feedback for