To deploy a version of your app with the Admin API, you define the
configuration details of your version using a JSON formatted file. You can
either manually create the configuration file or convert an existing app.yaml
file.
There are two parts to creating a JSON formatted configuration file:
- Define the configuration information for the version that you want to deploy.
- Define a
deploymentsection to specify all your app's files and resources that you want to deploy.
Before you begin
You must first upload all the files and resources of your app to a
Cloud Storage bucket
before you can create the app.json configuration file.
Manually creating the JSON configuration file
Use the following steps if you need to manually create the configuration file,
for example, when your app excludes an app.yaml or your existing Java app
uses an appengine-web.xml file.
To manually create the app.json configuration file for deploying your app with
the Admin API:
- Create a file name
app.json. - Use the configuration information that is provided in the apps.services.versions collection to define and configure the version that you want to deploy.
- Use the template in the Defining the
deploymentsection to specify all the files and resources that you want to deploy from your Cloud Storage bucket.
Also see the Example section below to assist you with
creating your app.json configuration file.
Converting an app.yaml file into the JSON format
You can use the convert_yaml.py tool to convert and generate an app.json
version from an existing app.yaml
file.
If an app.yaml file exists, which you normally use to manually deploy
versions of your app, you can
retain that information by converting those configuration settings into the JSON
format.
Prerequisite
Download and install the
convert_yaml.py tool, including the specified requirements.
Converting YAML files with the convert_yaml.py tool
To convert your app.yaml file with the convert_yaml.py tool:
Locate and note the directory path to your
app.yaml.Example:
cd root/apps-container/my-application/Where the
app.yamlof theexample-python-app.pyapplication might look like:service: default version: v1 runtime: python27 threadsafe: true handlers: - url: /.* script: example-python-app.pyNavigate to the local directory where you downloaded the
convert_yaml.pytool, for example:cd root/tools/appengine-config-transformerCreate the
app.jsonfile from theapp.yamlfile by running theconvert_yaml.pytool:python ./convert_yaml.py [DIRECTORY_PATH]/app.yaml > [DIRECTORY_PATH]/app.jsonWhere
[DIRECTORY_PATH]is the directory path to yourapp.yamlfile.A JSON version (
app.json) of yourapp.yamlfile is created in the[DIRECTORY_PATH]directory.Ensure that the ID of your version is defined in the
app.jsonconfiguration file.If your
app.yamlfile excludes theversion: [VERSION_NAME]element, then the"id": [VERSION_NAME]element is not included in yourapp.jsonfile after the conversion. For example, if you want to set your version ID tov1, you must manually add the following line to yourapp.jsonfile:"id": "v1",Use the template in the Defining the
deploymentsection to specify all the files and resources of your app that you want to deploy.
Also see the Example section below to assist you with
creating your app.json configuration file.
Defining the deployment section
To create a deployment section in the app.json configuration file and
manually define all of the resources that are located in your Cloud Storage
bucket, you use the reference information in the deployment
section
of the apps.services.versions collection. If you are defining individual
files, you can use the following template:
"deployment": {
"files": {
"my-resource-file1": {
"sourceUrl": "https://storage.googleapis.com/[MY_BUCKET_ID]/my-application/my-resource-file1"
},
}
},
Where my-resource-file1 defines the file name and relative directory
path of where you want to deploy that file in App Engine.
Example app.json file
Use the following example app.json to help you create your configuration file.
In the following app.json example, the v1 version ID is defined along with a
deployment
section that includes two example source files from the [MY_BUCKET_ID]
Cloud Storage bucket.
{
"deployment": {
"files": {
"example-resource-file1": {
"sourceUrl": "https://storage.googleapis.com/[MY_BUCKET_ID]/example-application/example-resource-file1"
},
"images/example-resource-file2": {
"sourceUrl": "https://storage.googleapis.com/[MY_BUCKET_ID]/example-application/images/example-resource-file2"
},
}
},
"id": "v1",
"handlers": [
{
"urlRegex": "/.*",
"script": {
"scriptPath": "example-python-app.py"
}
},
],
"runtime": "python27",
"threadsafe": true,
}