Une fois le développement et les tests en local effectués avec Apigee dans VS Code, vous êtes prêt à déployer votre API en tant qu'archive dans un environnement Apigee. Au cours de cette étape, vous allez créer un environnement Apigee compatible avec le déploiement d'archive et déployer une archive de la configuration de proxy de votre API dans l'environnement Apigee.
Suivez les étapes décrites dans la section Créer un environnement pour effectuer les opérations suivantes :
Créez un environnement dev dans votre organisation Apigee en activant le type de déploiement Archive. Utilisez l'UI ou l'API.
Assurez-vous que le groupe d'environnement a été créé avant de continuer. Vous pouvez vérifier l'état de votre nouveau groupe à l'aide d'une requête semblable à celle-ci :
Associer un environnement au groupe permet de rendre les proxys de cet environnement routables via les noms d'hôte du groupe. Cela déclenche une opération de longue durée qui peut prendre plusieurs minutes. Nous vous recommandons d'attendre une ou deux minutes avant de passer à l'étape suivante. En attendant, vous pouvez vérifier l'état de l'opération comme avant.
Déployez une archive de la configuration de proxy de votre API dans l'environnement Apigee.
Dans l'onglet Terminal d'Apigee VS Code, accédez au répertoire myapigeeworkspace.
cd myapigeeworkspace
Lorsque vous exécutez ls, le répertoire doit contenir le dossier src.
Pour plus d'informations sur les variables de cet exemple et sur la configuration de l'accès à l'API, consultez la section Déployer un exemple de proxy.
Le message d'erreur suivant s'affiche :
{"fault":{"faultstring":"Failed to resolve API Key variable request.queryparam.apikey",
"detail":{"errorcode":"steps.oauth.v2.FailedToResolveAPIKey"}}}
Pour obtenir une clé API, vous devez créer un produit d'API incluant l'API helloworld, puis créer et enregistrer un développeur avec ce produit d'API.
Obtenir une clé API
Créez un produit d'API à l'aide de l'interface utilisateur d'Apigee.
Sélectionnez Publier > Produits API.
Cliquez sur + Créer.
Saisissez les détails du produit API.
Saisissez les informations suivantes dans les champs correspondants :
Champ
Paramètre
Name:
myproduct
Display name:
myproduct
Environment:
dev
Access:
Public
Quota:
Laissez le champ vide
Allowed OAuth scope:
Laissez le champ vide
Dans la section Opérations, cliquez sur + Ajouter une opération.
Sous Source, sélectionnez helloworld dans le menu déroulant du proxy d'API.
Sous Opération, saisissez / dans le champ "Chemin d'accès".
Conservez les valeurs par défaut des autres champs.
Cliquez sur Save (Enregistrer) pour enregistrer l'opération.
Cliquez sur Save (Enregistrer) pour enregistrer le produit d'API.
Créez un développeur dans votre organisation :
Sélectionnez Publier > Développeurs dans le menu de navigation.
Cliquez sur + Développeur.
Saisissez les informations suivantes dans les champs correspondants :
Champ
Paramètre
First Name:
Alex
Last Name:
Hamilton
Username:
ahamilton
Email:
ahamilton@example.com
Cliquez sur Créer.
Enregistrer une application
Sélectionnez Publier > Applications.
Cliquez sur + App (+ Application).
Saisissez les informations suivantes dans les champs correspondants :
Champ
Paramètre
Name:
myapp
Display name:
myapp
Developer:
ahamilton@example.com
Callback URL:
Laissez le champ vide
Notes:
Laissez le champ vide
Expiry:
Jamais
Product:
Cliquez sur Ajouter un produit.
Sélectionnez myproduct.
Cliquez sur Ajouter.
Custom attributes:
Laissez le champ vide
Copiez la clé API.
Sur la page "Applications" (Publier > Applications), cliquez sur myapp.
Sur la page myapp, cliquez sur Afficher à côté de Clé dans la section Identifiants. Notez que la clé API est associée au produit d'API que vous avez créé.
Sélectionnez et copiez la clé API.
Exécutez à nouveau l'appel curl en transmettant la clé API à l'aide du paramètre de requête apikey, comme suit :
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eThis guide outlines how to deploy an API archive to an Apigee environment after local development and testing in VS Code, applicable to both Apigee and Apigee hybrid.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves creating a new 'dev' environment in your Apigee organization, enabling 'Archive' as the deployment type, and attaching this environment to a runtime instance and environment group.\u003c/p\u003e\n"],["\u003cp\u003eAfter creating the environment, you deploy the API proxy configuration archive to the newly created environment using the \u003ccode\u003egcloud beta apigee archives deploy\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eYou will need to create an API product, a developer, and register an app in order to obtain an API key to successfully test the deployed API.\u003c/p\u003e\n"],["\u003cp\u003eAfter testing the deployment with an API key, you can use this new flow for promoting the API archive to an Apigee production environment.\u003c/p\u003e\n"]]],[],null,["# Step 7: Deploy to an Apigee environment\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\n\u003cbr /\u003e\n\nAfter you complete local development and testing with Apigee in VS Code, you are ready to deploy your API as an archive to an Apigee\nenvironment. In this step, you'll create an Apigee environment that supports archive deployment and deploy an archive of your API proxy configuration to the Apigee environment.\n| **Before you begin** : Install Google Cloud SDK and the `gcloud beta apigee` component, as described in [Getting started using gcloud with Apigee](/apigee/docs/api-platform/get-started/gcloud-get-started).\n\n1. Follow the steps in [Create an environment](https://cloud.google.com/apigee/docs/api-platform/get-started/install-cli#create-environment) to perform the following:\n 1. Create a new **dev** environment in your Apigee organization, enabling **Archive** as the deployment type. Use the [UI](https://cloud.google.com/apigee/docs/api-platform/fundamentals/environments-working-with#creating-a-new-environment-in-the-ui) or [API](/apigee/docs/reference/apis/apigee/rest/v1/organizations.environments/create).\n 2. Attach the environment to a runtime instance using the [Instances attachment API](/apigee/docs/reference/apis/apigee/rest/v1/organizations.instances.attachments).\n\n\n This command triggers a long-running operation. Ensure that the environment has been attached to the runtime before continuing.\n 3. Create an environment group if you do not already have one using the [Create environment groups API](/apigee/docs/reference/apis/apigee/rest/v1/organizations.envgroups/create).\n\n\n Ensure that the environment group has been created before continuing. You can check the status of your new group using a\n request like the following: \n\n ```\n curl -i -H \"$AUTH\" -H \"Content-Type:application/json\" \\\n \"https://apigee.googleapis.com/v1/organizations/$PROJECT_ID/environments/ENVIRONMENT_NAME\"\n ```\n 4. Attach the new environment to the environment group using the [Environment group attachment API](/apigee/docs/reference/apis/apigee/rest/v1/organizations.envgroups.attachments).\n\n Attaching an environment to the group makes the proxies in that environment\n routable via the hostnames in the group. This triggers a long-running operation that can take several minutes to complete. We recommend that you wait a minute or two before continuing to the next step. In the meantime you can check the status of the operation as before.\n2. Deploy an archive of your API proxy configuration to the Apigee environment.\n 1. In the **Terminal** tab in Apigee VS Code, navigate to the **myapigeeworkspace** directory. \n\n ```\n cd myapigeeworkspace\n ```\n\n\n When you run `ls` the directory should contain the `src` folder.\n 2. Run the following command: \n\n ```\n gcloud beta apigee archives deploy --environment=dev --labels=release=052021\n ```\n\n\n The following provides an example of the response: \n\n ```\n Using Apigee organization dev\n Waiting for operation [b64c2665-b5ac-43cc-9e2d-232e8895c2ed] to complete...done\n ```\n3. Run the following command in the **Terminal** tab to test your API: \n\n ```\n curl https://INTERNAL_LOAD_BALANCER_IP/helloworld /\n -H \"Host: ENV_GROUP_HOSTNAME\" \n ```\n\n\n For more information about the variables in this example and how to set up API access, see [Deploy a sample proxy](/apigee/docs/api-platform/get-started/deploy-sample).\n\n\n The following error message is displayed: \n\n ```\n {\"fault\":{\"faultstring\":\"Failed to resolve API Key variable request.queryparam.apikey\",\n \"detail\":{\"errorcode\":\"steps.oauth.v2.FailedToResolveAPIKey\"}}}\n ```\n\n\n You need to create an API product that includes the `helloworld` API, then create and register a developer with the API product in order to obtain an API key.\n4. Obtain an API key.\n 1. Create an API product using the Apigee UI:\n 1. Go to the API products page: \n\n ### Apigee in Cloud console\n\n In the Google Cloud console, go to the **Distribution \\\u003e API products** page.\n\n [Go to API products](https://console.cloud.google.com/apigee/apiproducts)\n\n ### Classic Apigee UI\n\n Select **Publish \\\u003e API Products**.\n 2. Click **+ Create**.\n 3. Enter the Product Details for your API product. \n 4. Enter the following information in the fields:\n\n 5. In the **Operations** section, click **+ Add an Operation**.\n 6. Under **Source** select **helloworld** from the API Proxy dropdown menu.\n 7. Under **Operation** , in the Path field, enter `/`.\n\n\n Leave other fields set to their defaults.\n 8. Click **Save** to save the Operation.\n 9. Click **Save** to save the API product.\n\n \u003cbr /\u003e\n\n 2. Create a developer in your organization: \n\n ### Apigee in Cloud console\n\n 1. In the Google Cloud console, go to the **Distribution \\\u003e Developers** page.\n\n [Go to Developers](https://console.cloud.google.com/apigee/developers)\n 2. Click **+ Create**.\n 3. Enter the following information in the fields:\n\n 4. Click **Add**.\n\n ### Classic Apigee UI\n\n 1. Select **Publish \\\u003e Developers** in the navigation menu.\n 2. Click **+ Developer**.\n 3. Enter the following information in the fields:\n\n 4. Click **Create**.\n 3. Register an app:\n 1. Open the app editor. \n\n ### Apigee in Cloud console\n\n 1. In the Google Cloud console, go to the **Distribution \\\u003e Apps** page.\n\n [Go to Apps](https://console.cloud.google.com/apigee/apps)\n 2. Click **+ Create**.\n\n ### Classic Apigee UI\n\n 1. Select **Publish \\\u003e Apps**.\n 2. Click **+ App**.\n 2. Enter the following information in the fields:\n\n 3. Click **Create**.\n 4. \n 4. Copy the API key.\n\n ### Apigee in Cloud console\n\n - In the Google Cloud console, go to the **Distribution \\\u003e Apps** page.\n\n [Go to Apps](https://console.cloud.google.com/apigee/apps)\n - Click **myapp**.\n - In the **Credentials** section, next to **Key** , click visibility_off **Show**.\n - Click content_copy **Copy**.\n\n ### Classic Apigee UI\n\n - On the Apps page (**Publish \\\u003e Apps** ), click **myapp**.\n\n - On the **myapp** page, click **Show** next to **Key** in the **Credentials** section. Notice that the API key is associated with the API product you created. \n - Select and copy the API key.\n\n5. Run the curl call again passing the API key using the `apikey` query parameter, as follows: \n\n ```\n curl -v https://$PUBLIC_FACING_IP/helloworld?apikey=ZQA5euYtNeJ7ZCGCJMpvd6F2BZOmxOzY\n ```\n\n The following response is returned: \n\n ```\n {\n \"root\": {\n \"city\": \"San Jose\",\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"state\": \"CA\"\n }\n }\n ```\n\n\u003cbr /\u003e\n\n**Congratulations!** You've successfully deployed your API archive to an Apigee environment!\n\nIn the next step, you'll promote your API archive to an Apigee production environment.\n\n\n[1](/apigee/docs/api-platform/local-development/vscode/tutorial-create-workspace)\n\n\n[2](/apigee/docs/api-platform/local-development/vscode/tutorial-create-proxy)\n\n\n[3](/apigee/docs/api-platform/local-development/vscode/tutorial-deploy)\n\n\n[4](/apigee/docs/api-platform/local-development/vscode/tutorial-test)\n\n\n[5](/apigee/docs/api-platform/local-development/vscode/tutorial-change-target-endpoint)\n\n\n[6](/apigee/docs/api-platform/local-development/vscode/tutorial-attach-policy)\n\n\n[7](/apigee/docs/api-platform/local-development/vscode/tutorial-deploy-apigee)\n\n\n[(NEXT) Step 8: Promote an archive to production](/apigee/docs/api-platform/local-development/vscode/tutorial-promote)\n\n\u003cbr /\u003e"]]