To deploy a version of your app with the Admin API, you define theconfiguration details of your version using a JSON formatted file. You caneither 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
deployment
section to specify all your app's files and resourcesthat you want to deploy.
Before you begin
You must first upload all the files and resources of your app to aCloud Storage bucketbefore 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 appuses an appengine-web.xml
file.
To manually create the app.json
configuration file for deploying your app withthe Admin API:
- Create a file name
app.json
. - Use the configuration information that is provided in theapps.services.versions collectionto 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 youwant to deploy from your Cloud Storage bucket.
Also see the Example section below to assist you withcreating 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 deployversions of your app, you canretain that information by converting those configuration settings into the JSONformat.
Prerequisite
Download and install theconvert_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:
See AlsoOrg.Json - Environment Setupcd root/apps-container/my-application/
Where the
app.yaml
of theexample-python-app.py
application might look like:service: defaultversion: v1runtime: python27threadsafe: truehandlers:- url: /.* script: example-python-app.py
Navigate to the local directory where you downloaded the
convert_yaml.py
tool, for example:cd root/tools/appengine-config-transformer
Create the
app.json
file from theapp.yaml
file by running theconvert_yaml.py
tool:python ./convert_yaml.py [DIRECTORY_PATH]/app.yaml > [DIRECTORY_PATH]/app.json
Where
[DIRECTORY_PATH]
is the directory path to yourapp.yaml
file.A JSON version (
app.json
) of yourapp.yaml
file is created in the[DIRECTORY_PATH]
directory.Ensure that the ID of your version is defined in the
app.json
configuration file.If your
app.yaml
file excludes theversion: [VERSION_NAME]
element,then the"id": [VERSION_NAME]
element is not included in yourapp.json
file after the conversion. For example, if you want to set yourversion ID tov1
, you must manually add the following line to yourapp.json
file:"id": "v1",
Use the template in the Defining the deploymentsection to specify all the files and resources ofyour app that you want to deploy.
Also see the Example section below to assist you withcreating your app.json
configuration file.
Defining the deployment
section
To create a deployment
section in the app.json
configuration file andmanually define all of the resources that are located in your Cloud Storagebucket, you use the reference information in the deployment
sectionof the apps.services.versions
collection. If you are defining individualfiles, 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 directorypath 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 adeployment
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,}