[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eCloud Endpoints uses the \u003ccode\u003egcloud endpoints services deploy\u003c/code\u003e command to deploy an OpenAPI document, which is essential for managing your API through Endpoints.\u003c/p\u003e\n"],["\u003cp\u003eBefore deploying, ensure you have a Google Cloud project, have configured Endpoints, and have verified your custom domain name if you are using one.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egcloud\u003c/code\u003e command-line tool is used for the deployment process and requires preparation steps, including installation, updating, authorization, and setting the default project.\u003c/p\u003e\n"],["\u003cp\u003eYou can validate your OpenAPI document using the \u003ccode\u003e--validate-only\u003c/code\u003e flag in the deployment command, which creates a service but does not deploy the configuration.\u003c/p\u003e\n"],["\u003cp\u003eRedeploying your OpenAPI document after changes is crucial for Endpoints to use the latest configuration, and it is recommended to use the \u003ccode\u003erollout\u003c/code\u003e option set to \u003ccode\u003emanaged\u003c/code\u003e for automatic updates.\u003c/p\u003e\n"]]],[],null,["# Deploying the Endpoints configuration\n\nOpenAPI \\| [gRPC](/endpoints/docs/grpc/deploy-endpoints-config \"View this page for the Cloud Endpoints gRPC docs\")\n\n\u003cbr /\u003e\n\nAfter you configure Cloud Endpoints in an [OpenAPI\ndocument](/endpoints/docs/openapi/glossary#open_api_doc), you deploy it so that\nEndpoints has the information that it needs to manage your API.\nTo deploy the Endpoints configuration, you use the [`gcloud\nendpoints services deploy`](/sdk/gcloud/reference/endpoints/services/deploy)\ncommand. This command uses\n[Service Infrastructure](/service-infrastructure/docs/overview), Google's\nfoundational services platform, used by Endpoints and other\nservices to create and manage APIs and services. This page describes how to\ndeploy an OpenAPI document to Endpoints.\n\nPrerequisites\n-------------\n\nAs a starting point, this page assumes that you have:\n\n- Created a [Google Cloud\n project](/resource-manager/docs/creating-managing-projects) in which you have\n the **Editor** or **Owner** role. After the initial deployment, you can grant\n the more restrictive **Service Config Editor** role to a user, group, or\n service account. See [Granting and revoking access to the\n API](/endpoints/docs/openapi/control-api-access) for more information.\n\n- [Configured Endpoints](/endpoints/docs/openapi/configure-endpoints).\n\n- If you are using a custom domain name (such as `my-api.example.com`), you must\n [verify the domain name](/endpoints/docs/openapi/verify-domain-name) before\n you can deploy the OpenAPI document.\n\nPreparing the Google Cloud CLI for deployment\n---------------------------------------------\n\nYou use the `gcloud` command line tool to\ndeploy the configuration. See the [gcloud Reference](/sdk/gcloud/reference) for more information about the commands.\n\nTo prepare for the deployment:\n\n1. Install and initialize the [gcloud CLI](/sdk/docs/install).\n2. Update gcloud CLI: \n\n ```text\n gcloud components update\n ```\n3. Make sure that gcloud CLI is authorized to access your data and services: \n\n ```text\n gcloud auth login\n ```\n\n A new browser tab opens and you are prompted to choose an account.\n4. Set the default project. Replace `[YOUR-PROJECT-ID]` with your GCP project ID \n\n ```text\n gcloud config set project [YOUR-PROJECT-ID]\n ```\n5. If you will be deploying your API backend to either Kubernetes or Kubernetes Engine, run the following command to acquire new user credentials to use for Application Default Credentials. The user credentials are needed to authorize `kubectl`. \n\n ```bash\n gcloud auth application-default login\n ```\n A new browser tab opens and you are prompted to choose an account.\n\nValidating `openapi.json` syntax\n--------------------------------\n\nThe OpenAPI document file can be in YAML format or JSON format. If it is in JSON\nformat, we recommend that you verify the syntax before deploying the file. To\ncheck that your `openapi.json` is a well-formatted JSON file, you can open it in\na JSON-validating text editor such as `vim`, use an online JSON linter\nservice, or use Python, for example: \n\n python -m json.tool openapi.json\n\nTo improve readability, you can pretty-print the JSON file: \n\n python -m json.tool input.json \u003e output.json\n\nReplace `input.json` with the path to your `openapi.json` file. `output.json` is\nthe pretty-printed JSON file.\n\nValidating your OpenAPI document\n--------------------------------\n\nNot all OpenAPI constructs are [currently supported by\nCloud Endpoints](/endpoints/docs/openapi/openapi-limitations). Before\ndeploying, you can validate your OpenAPI document.\n\nTo validate your OpenAPI document:\n\n1. Change directory to the location containing your OpenAPI document.\n\n2. Confirm the Google Cloud project where you want to create the service.\n If you are using a custom domain name (such as, `myapi.example.com`),\n make sure to validate the project ID returned from the following command\n so that the service isn't created in the wrong project.\n\n gcloud config list project\n\n If you need to change the default project, run the following command\n and replace `[YOUR_PROJECT_ID]` with the Google Cloud project ID\n in which you want to create the service: \n\n gcloud config set project [YOUR_PROJECT_ID]\n\n3. Run the following command, and replace `[YOUR_OPENAPI_DOCUMENT]` with\n the name of the OpenAPI document that describes your API:\n\n gcloud endpoints services deploy [YOUR_OPENAPI_DOCUMENT] --validate-only\n\nThe `gcloud` command then calls the\n[Service Management](/service-infrastructure/docs/manage-config) API to\ncreate a managed service with the name that you specified in the `host` field\nin your OpenAPI document. When you specify the `--validate-only` flag, a service\nis still created, but the configuration isn't deployed. There isn't a way to\nvalidate your OpenAPI document without creating a service. Although you can\n[delete the service](/endpoints/docs/openapi/deleting-an-api-and-instances),\nService Management prevents you from creating a service with the same\nname for a period of approximately 30 days.\n\nDeploying the OpenAPI document\n------------------------------\n\nWhen you are ready to deploy your API, you run the Google Cloud CLI,\nwhich uses Service Management to upload your API configuration and\nto create (or update) a managed service.\n\nTo deploy your OpenAPI document:\n\n1. Change directory to the location containing your OpenAPI document.\n\n2. Validate the project ID returned from the following command to make sure that\n the service isn't created in the wrong project.\n\n gcloud config list project\n\n If you need to change the default project, run the following command\n and replace `[YOUR_PROJECT_ID]` with the Google Cloud project ID\n in which you want to create the service:: \n\n gcloud config set project [YOUR_PROJECT_ID]\n\n3. Run the following command, and replace `[YOUR_OPENAPI_DOCUMENT]` with\n the name of the OpenAPI document that describes your API:\n\n gcloud endpoints services deploy [YOUR_OPENAPI_DOCUMENT]\n\nThe first time that you run the previous command, Service Management\ncreates a new Endpoints service in the default project with a\nname that matches the text that you specified in the `host` field in your\nOpenAPI document and uploads your service configuration.\n\nAs it is creating and configuring the service, Service Management outputs\ninformation to the terminal. On successful completion, you see a line like the\nfollowing that displays the service configuration ID and the service name: \n\n```\nService Configuration [2017-02-13r0] uploaded for service [echo-api.endpoints.example-project-12345.cloud.goog]\n```\n\nIn the previous example, `2017-02-13r0` is the service configuration\nID and `echo-api.endpoints.example-project-12345.cloud.goog` is the service\nname.\n\nAfter a successful deployment,\nyou can view the API on the\n[**Endpoints** \\\u003e **Services**](https://console.cloud.google.com/endpoints)\npage in the Google Cloud console.\n\nIf you get an error message, see [Troubleshooting Endpoints\nconfiguration\ndeployment](/endpoints/docs/openapi/troubleshoot-config-deployment).\n\nRedeploying\n-----------\n\nWhenever you change something in your OpenAPI document, be sure to deploy it\nagain so that Endpoints has the most recent version of\nyour API's service configuration. You don't need to redeploy\nor restart ESP if you previously deployed ESP with\nthe\n[`rollout` option set to `managed`](/endpoints/docs/openapi/deploy-api-backend#deploying_your_api_and_esp).\nThis option\nconfigures ESP to use the latest deployed service configuration. When you\nspecify this option, up to 5 minutes after you deploy a new service\nconfiguration, ESP detects the change and automatically begins using it. We\nrecommend that you specify this option instead of a specific configuration ID\nfor ESP to use.\n\nAfter the initial Endpoints configuration deployment, you can\ngrant a user, service account, or group a role that allows them to redeploy the\nEndpoints configuration. See [Granting and revoking access to the\nAPI](/endpoints/docs/openapi/control-api-access) for more information.\n\nWhat's next\n-----------\n\n- [Deploying the API backend](/endpoints/docs/openapi/deploy-api-backend)\n- [Deploying on Kubernetes](/endpoints/docs/openapi/kubernetes-concept)\n- [Running ESP locally or on another platform](/endpoints/docs/openapi/running-esp-localdev)\n- [Getting the service name and configuration ID](/endpoints/docs/openapi/get-service-name-config-id)"]]