Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite erfahren Sie, wie Sie Function Frameworks für die lokale Entwicklung installieren und ausführen.
Hinweise
Wenn Sie Cloud Run-Funktionen zum ersten Mal mit Cloud Code verwenden, lesen Sie die Kurzanleitung zu Cloud Run-Funktionen. Nachdem Sie eine Funktion mit einem Cloud Code-Beispiel erstellt und bereitgestellt haben, können Sie zu dieser Anleitung zurückkehren, um eine lokale Entwicklungsumgebung einzurichten.
Functions Framework lokal installieren und ausführen
So installieren und führen Sie das Functions Framework lokal aus:
Klicken Sie in VS Code auf Cloud Code und maximieren Sie den Cloud Functions Explorer.
Maximieren Sie das Google Cloud Projekt, klicken Sie mit der rechten Maustaste auf eine bereitgestellte Funktion Ihrer Wahl und wählen Sie In neuen Arbeitsbereich herunterladen aus. Dadurch wird der Quellcode Ihrer Funktion von Google Cloud auf Ihren lokalen Computer heruntergeladen und ein neuer Arbeitsbereich in Ihrer IDE erstellt.
Klicken Sie auf Ansicht > Terminal, um das Terminal in VS Code zu öffnen.
Wenn Sie die lokalen Abhängigkeiten im lokalen Ordner Ihrer Funktion installieren möchten, rufen Sie im Terminal den lokalen Ordner Ihrer Funktion auf und führen Sie dann Folgendes aus:
Node.js
npminstall
Python
pipinstallfunctions-framework
Führen Sie zum Ausführen des lokalen Functions Framework Folgendes aus:
Node.js
npxfunctions-framework--target=entryPoint
Python
functions-framework--target=entryPoint
Wenn Sie den entryPoint Ihrer Funktion ermitteln möchten, öffnen Sie die Datei launch.json und suchen Sie nach dem zugewiesenen Wert für entryPoint.
Wenn Sie beispielsweise die Beispielanwendung „Hello World“ von Cloud Code verwenden, sieht die Konfiguration so aus:
"entryPoint": "helloHttp",
Klicken Sie zum Testen der Funktion auf die Aufforderung Im Browser öffnen oder auf + Neues Terminal und führen Sie Folgendes aus:
curl http://localhost:8080/
Dadurch wird der Kontext der Funktion im Terminal angezeigt.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-05 (UTC)."],[[["\u003cp\u003eThis page guides you through installing and running Functions Framework locally for development purposes.\u003c/p\u003e\n"],["\u003cp\u003eYou can download a deployed function's source code to your local machine by using the Cloud Code extension in VS Code.\u003c/p\u003e\n"],["\u003cp\u003eInstall the necessary dependencies for your function locally using either \u003ccode\u003enpm install\u003c/code\u003e for Node.js or \u003ccode\u003epip install functions-framework\u003c/code\u003e for Python.\u003c/p\u003e\n"],["\u003cp\u003eRun Functions Framework locally by executing \u003ccode\u003enpx functions-framework --target=entryPoint\u003c/code\u003e (Node.js) or \u003ccode\u003efunctions-framework --target=entryPoint\u003c/code\u003e (Python), with the entry point specified in your \u003ccode\u003elaunch.json\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eYou can test your locally running function by opening it in a browser or by using curl with \u003ccode\u003ehttp://localhost:8080/\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Run locally with Functions Framework\n\nThis page shows you how to install and run\n[Functions Frameworks](/functions/docs/functions-framework) for local\ndevelopment.\n\nBefore you begin\n----------------\n\nIf this is your first time using [Cloud Run functions](/run/docs/functions-with-run)\nwith Cloud Code, see the\n[Get started with Cloud Run functions](/functions/docs/get-started-in-cloud-run)\nquickstart. Once you've created and deployed a function using a\nCloud Code sample, you can return to this guide to setup a local\ndevelopment environment.\n\nInstall and run Functions Framework locally\n-------------------------------------------\n\nTo install and run Functions Framework locally, follow these steps:\n\n1. In VS Code, click\n\n **Cloud Code** and then expand the **Cloud Functions** explorer.\n\n2. Expand your Google Cloud project, right-click a deployed function of\n your choice, and select **Download to new workspace**. This downloads the source\n code of your function from Google Cloud to your local machine and\n creates a new workspace in your IDE.\n\n3. Click **View** \\\u003e **Terminal**\n to open the terminal in VS Code.\n\n4. To install the local dependencies to your function's local folder, navigate\n to your function's local folder in the terminal and then run the following:\n\n ### Node.js\n\n npm install\n\n ### Python\n\n pip install functions-framework\n\n5. To run the local Functions Framework, run the following:\n\n ### Node.js\n\n ```bash\n npx functions-framework --target=entryPoint\n ```\n\n ### Python\n\n ```bash\n functions-framework --target=entryPoint\n ```\n\n To find the `entryPoint` of your function, open your `launch.json` file and\n look for the assigned value of `entryPoint`.\n\n For example, if you're using Cloud Code's Hello World sample\n application, the configuration appears as follows: \n\n \"entryPoint\": \"helloHttp\",\n\n6. To test your function, when prompted, click **Open in Browser** , or click\n **+ New Terminal** and run the following:\n\n curl http://localhost:8080/\n\n | **Note:** By default, your function will be accessible at `localhost:8080`.\n\n This shows the context of the function in the terminal.\n\nFor more information on how to call locally running functions, see\n[Local functions development](/run/docs/local-dev-functions).\n\nGet Support\n-----------\n\nTo send feedback, report issues on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-vscode/issues), or ask a question on [Stack Overflow](https://stackoverflow.com/questions/ask?tags=cloud-code-vscode)."]]