הדרכה בנושא Cloud Storage (דור ראשון)

במדריך הפשוט הזה נסביר איך לכתוב, לפרוס ולהפעיל פונקציית Cloud Run מבוססת-אירועים באמצעות טריגר של Cloud Storage כדי להגיב לאירועים ב-Cloud Storage.

אם אתם מחפשים דוגמאות קוד לשימוש ב-Cloud Storage, היכנסו לדפדפן לדוגמה של Google Cloud.

מטרות

עלויות

במסמך הזה משתמשים ברכיבים הבאים של Google Cloud, והשימוש בהם כרוך בתשלום:

  • Cloud Run functions
  • Cloud Storage

בעזרת מחשבון העלויות אתם יכולים להעריך את העלויות בהתאם לשימוש הצפוי.

משתמשים חדשים של Google Cloud ? יכול להיות שאתם זכאים לתקופת ניסיון בחינם.

לפני שמתחילים

  1. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  2. Verify that billing is enabled for your Google Cloud project.

  3. Enable the Cloud Functions, Cloud Build, Cloud Storage, and Eventarc APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  4. Install the Google Cloud CLI.

  5. Configure the gcloud CLI to use your federated identity.

    For more information, see Sign in to the gcloud CLI with your federated identity.

  6. To initialize the gcloud CLI, run the following command:

    gcloud init

    אם כבר התקנתם את ה-CLI של gcloud, עדכנו אותו באמצעות הפקודה הבאה:

    gcloud components update
  7. הכנת סביבת הפיתוח:

האפליקציה בהכנה

  1. יוצרים קטגוריה של Cloud Storage כדי להעלות קובץ בדיקה, כאשר YOUR_TRIGGER_BUCKET_NAME הוא שם ייחודי גלובלי של קטגוריה:

    gcloud storage buckets create gs://YOUR_TRIGGER_BUCKET_NAME
  2. משכפלים את המאגר של האפליקציה לדוגמה ומעבירים אותו למכונה המקומית:

    Node.js

    git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git

    אפשר גם להוריד את קובץ ה-ZIP לדוגמה ולחלץ אותו.

    Python

    git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git

    אפשר גם להוריד את קובץ ה-ZIP לדוגמה ולחלץ אותו.

    המשך

    git clone https://github.com/GoogleCloudPlatform/golang-samples.git

    אפשר גם להוריד את קובץ ה-ZIP לדוגמה ולחלץ אותו.

    Java

    git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git

    אפשר גם להוריד את קובץ ה-ZIP לדוגמה ולחלץ אותו.

    Ruby

    git clone https://github.com/GoogleCloudPlatform/ruby-docs-samples.git

    אפשר גם להוריד את קובץ ה-ZIP לדוגמה ולחלץ אותו.

  3. עוברים לספרייה שמכילה את הקוד לדוגמה של פונקציות Cloud Run:

    Node.js

    cd nodejs-docs-samples/functions/helloworld/

    Python

    cd python-docs-samples/functions/helloworld/

    Go

    cd golang-samples/functions/helloworld/

    Java

    cd java-docs-samples/functions/helloworld/hello-gcs/

    Ruby

    cd ruby-docs-samples/functions/helloworld/storage/

פריסה והפעלה של הפונקציה

הפונקציות של Cloud Storage מבוססות על התראות Pub/Sub מ-Cloud Storage, והן תומכות בסוגי אירועים דומים:

בקטעים הבאים מוסבר איך לפרוס ולהפעיל פונקציה לכל אחד מסוגי האירועים האלה.

סיום אובייקט

אירועי סיום של אובייקטים מופעלים כש "כתיבה" של אובייקט Cloud Storage מסתיימת בהצלחה. באופן ספציפי, המשמעות היא שיצירת אובייקט חדש או החלפת אובייקט קיים מפעילות את האירוע הזה. הטריגר הזה מתעלם מפעולות של העברה לארכיון ועדכון מטא-נתונים.

‫Object Finalize: פריסת הפונקציה

הנה דוגמה לפונקציה שמטפלת באירועים של Cloud Storage:

Node.js

/**
 * Generic background Cloud Function to be triggered by Cloud Storage.
 * This sample works for all Cloud Storage CRUD operations.
 *
 * @param {object} file The Cloud Storage file metadata.
 * @param {object} context The event metadata.
 */
exports.helloGCS = (file, context) => {
  console.log(`  Event: ${context.eventId}`);
  console.log(`  Event Type: ${context.eventType}`);
  console.log(`  Bucket: ${file.bucket}`);
  console.log(`  File: ${file.name}`);
  console.log(`  Metageneration: ${file.metageneration}`);
  console.log(`  Created: ${file.timeCreated}`);
  console.log(`  Updated: ${file.updated}`);
};

Python

def hello_gcs(event, context):
    """Background Cloud Function to be triggered by Cloud Storage.
       This generic function logs relevant data when a file is changed,
       and works for all Cloud Storage CRUD operations.
    Args:
        event (dict):  The dictionary with data specific to this type of event.
                       The `data` field contains a description of the event in
                       the Cloud Storage `object` format described here:
                       https://cloud.google.com/storage/docs/json_api/v1/objects#resource
        context (google.cloud.functions.Context): Metadata of triggering event.
    Returns:
        None; the output is written to Cloud Logging
    """

    print(f"Event ID: {context.event_id}")
    print(f"Event type: {context.event_type}")
    print("Bucket: {}".format(event["bucket"]))
    print("File: {}".format(event["name"]))
    print("Metageneration: {}".format(event["metageneration"]))
    print("Created: {}".format(event["timeCreated"]))
    print("Updated: {}".format(event["updated"]))

Go


// Package helloworld provides a set of Cloud Functions samples.
package helloworld

import (
	"context"
	"fmt"
	"log"
	"time"

	"cloud.google.com/go/functions/metadata"
)

// GCSEvent is the payload of a GCS event.
type GCSEvent struct {
	Kind                    string                 `json:"kind"`
	ID                      string                 `json:"id"`
	SelfLink                string                 `json:"selfLink"`
	Name                    string                 `json:"name"`
	Bucket                  string                 `json:"bucket"`
	Generation              string                 `json:"generation"`
	Metageneration          string                 `json:"metageneration"`
	ContentType             string                 `json:"contentType"`
	TimeCreated             time.Time              `json:"timeCreated"`
	Updated                 time.Time              `json:"updated"`
	TemporaryHold           bool                   `json:"temporaryHold"`
	EventBasedHold          bool                   `json:"eventBasedHold"`
	RetentionExpirationTime time.Time              `json:"retentionExpirationTime"`
	StorageClass            string                 `json:"storageClass"`
	TimeStorageClassUpdated time.Time              `json:"timeStorageClassUpdated"`
	Size                    string                 `json:"size"`
	MD5Hash                 string                 `json:"md5Hash"`
	MediaLink               string                 `json:"mediaLink"`
	ContentEncoding         string                 `json:"contentEncoding"`
	ContentDisposition      string                 `json:"contentDisposition"`
	CacheControl            string                 `json:"cacheControl"`
	Metadata                map[string]interface{} `json:"metadata"`
	CRC32C                  string                 `json:"crc32c"`
	ComponentCount          int                    `json:"componentCount"`
	Etag                    string                 `json:"etag"`
	CustomerEncryption      struct {
		EncryptionAlgorithm string `json:"encryptionAlgorithm"`
		KeySha256           string `json:"keySha256"`
	}
	KMSKeyName    string `json:"kmsKeyName"`
	ResourceState string `json:"resourceState"`
}

// HelloGCS consumes a(ny) GCS event.
func HelloGCS(ctx context.Context, e GCSEvent) error {
	meta, err := metadata.FromContext(ctx)
	if err != nil {
		return fmt.Errorf("metadata.FromContext: %w", err)
	}
	log.Printf("Event ID: %v\n", meta.EventID)
	log.Printf("Event type: %v\n", meta.EventType)
	log.Printf("Bucket: %v\n", e.Bucket)
	log.Printf("File: %v\n", e.Name)
	log.Printf("Metageneration: %v\n", e.Metageneration)
	log.Printf("Created: %v\n", e.TimeCreated)
	log.Printf("Updated: %v\n", e.Updated)
	return nil
}

Java

import com.google.cloud.functions.BackgroundFunction;
import com.google.cloud.functions.Context;
import functions.eventpojos.GcsEvent;
import java.util.logging.Logger;

/**
 * Example Cloud Storage-triggered function.
 * This function can process any event from Cloud Storage.
 */
public class HelloGcs implements BackgroundFunction<GcsEvent> {
  private static final Logger logger = Logger.getLogger(HelloGcs.class.getName());

  @Override
  public void accept(GcsEvent event, Context context) {
    logger.info("Event: " + context.eventId());
    logger.info("Event Type: " + context.eventType());
    logger.info("Bucket: " + event.getBucket());
    logger.info("File: " + event.getName());
    logger.info("Metageneration: " + event.getMetageneration());
    logger.info("Created: " + event.getTimeCreated());
    logger.info("Updated: " + event.getUpdated());
  }
}

Ruby

require "functions_framework"

FunctionsFramework.cloud_event "hello_gcs" do |event|
  # This function supports all Cloud Storage events.
  # The `event` parameter is a CloudEvents::Event::V1 object.
  # See https://cloudevents.github.io/sdk-ruby/latest/CloudEvents/Event/V1.html
  payload = event.data

  logger.info "Event: #{event.id}"
  logger.info "Event Type: #{event.type}"
  logger.info "Bucket: #{payload['bucket']}"
  logger.info "File: #{payload['name']}"
  logger.info "Metageneration: #{payload['metageneration']}"
  logger.info "Created: #{payload['timeCreated']}"
  logger.info "Updated: #{payload['updated']}"
end

כדי לפרוס את הפונקציה, מריצים את הפקודה הבאה בספרייה שבה נמצא הקוד לדוגמה:

Node.js

gcloud functions deploy helloGCS \
--runtime nodejs22 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.finalize

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Node.js נתמכת להרצת הפונקציה.

Python

gcloud functions deploy hello_gcs \
--runtime python312 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.finalize

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Python נתמכת להרצת הפונקציה.

המשך

gcloud functions deploy HelloGCS \
--runtime go121 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.finalize

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Go נתמכת להרצת הפונקציה.

Java

gcloud functions deploy java-gcs-function \
--entry-point functions.HelloGcs \
--runtime java17 \
--memory 512MB \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.finalize

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Java נתמכת להרצת הפונקציה.

Ruby

gcloud functions deploy hello_gcs --runtime ruby33 \
-
-trigger-resource YOUR_TRIGGER_BUCKET_NAME \
-
-trigger-event google.storage.object.finalize

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Ruby נתמכת להרצת הפונקציה.

כאשר YOUR_TRIGGER_BUCKET_NAME הוא השם של הקטגוריה של Cloud Storage שמפעילה את הפונקציה.

סיום אובייקט: הפעלת הפונקציה

כדי להפעיל את הפונקציה:

  1. יוצרים קובץ gcf-test.txt ריק בספרייה שבה נמצא הקוד לדוגמה.

  2. מעלים את הקובץ ל-Cloud Storage כדי להפעיל את הפונקציה:

    gcloud storage cp gcf-test.txt gs://YOUR_TRIGGER_BUCKET_NAME

    כאשר YOUR_TRIGGER_BUCKET_NAME הוא השם של הקטגוריה של Cloud Storage שאליה תעלו קובץ בדיקה.

  3. בודקים ביומנים כדי לוודא שההפעלות הושלמו:

    gcloud functions logs read --limit 50
    

מחיקת אובייקט

אירועי מחיקת אובייקטים מופעלים כשמתבצעת מחיקה עם יכולת שחזור של אובייקט. זה קורה כשמחליפים או מוחקים אובייקט בקטגוריה שלא מופעל בה ניהול גרסאות של אובייקטים. אם מוחקים אובייקט על ידי ציון מספר הגנרציה שלו, האובייקט נמחק עם יכולת שחזור.

מחיקת אובייקט: פריסת הפונקציה

באמצעות אותו קוד לדוגמה כמו בדוגמה של finalize, פורסים את הפונקציה עם מחיקת אובייקט כאירוע הטריגר. מריצים את הפקודה הבאה בספרייה שבה נמצא הקוד לדוגמה:

Node.js

gcloud functions deploy helloGCS \
--runtime nodejs22 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.delete

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Node.js נתמכת להרצת הפונקציה.

Python

gcloud functions deploy hello_gcs \
--runtime python312 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.delete

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Python נתמכת להרצת הפונקציה.

המשך

gcloud functions deploy HelloGCS \
--runtime go121 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.delete

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Go נתמכת להרצת הפונקציה.

Java

gcloud functions deploy java-gcs-function \
--entry-point functions.HelloGcs \
--runtime java17 \
--memory 512MB \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.delete

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Java נתמכת להרצת הפונקציה.

Ruby

gcloud functions deploy hello_gcs --runtime ruby33 \
-
-trigger-resource YOUR_TRIGGER_BUCKET_NAME \
-
-trigger-event google.storage.object.delete

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Ruby נתמכת להרצת הפונקציה.

כאשר YOUR_TRIGGER_BUCKET_NAME הוא השם של הקטגוריה של Cloud Storage שמפעילה את הפונקציה.

מחיקת אובייקט: הפעלת הפונקציה

כדי להפעיל את הפונקציה:

  1. יוצרים קובץ gcf-test.txt ריק בספרייה שבה נמצא הקוד לדוגמה.

  2. מוודאים שהקטגוריה לא מוגדרת עם ניהול גרסאות:

    gcloud storage buckets update gs://YOUR_TRIGGER_BUCKET_NAME --no-versioning
  3. מעלים את הקובץ ל-Cloud Storage:

    gcloud storage cp gcf-test.txt gs://YOUR_TRIGGER_BUCKET_NAME

    כאשר YOUR_TRIGGER_BUCKET_NAME הוא השם של הקטגוריה של Cloud Storage שאליה תעלו קובץ בדיקה. בשלב הזה, הפונקציה עדיין לא אמורה לפעול.

  4. מוחקים את הקובץ כדי להפעיל את הפונקציה:

    gcloud storage rm gs://YOUR_TRIGGER_BUCKET_NAME/gcf-test.txt
  5. בודקים ביומנים כדי לוודא שההפעלות הושלמו:

    gcloud functions logs read --limit 50
    

שימו לב: יכול להיות שיעבור זמן מה עד שהפונקציה תסיים לפעול.

ארכיון האובייקטים

אירועי העברה לארכיון של אובייקטים מופעלים כשגרסה פעילה של אובייקט הופכת לגרסה לא עדכנית. זה קורה כשמחליפים או מוחקים אובייקט בקטגוריה שבה מופעלת התכונה ניהול גרסאות של אובייקטים.

‫Object Archive: פריסת הפונקציה

באמצעות אותו קוד לדוגמה כמו בדוגמה של finalize, פורסים את הפונקציה עם אירוע הטריגר של העברה לארכיון של אובייקט. מריצים את הפקודה הבאה בספרייה שבה נמצא הקוד לדוגמה:

Node.js

gcloud functions deploy helloGCS \
--runtime nodejs22 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.archive

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Node.js נתמכת להרצת הפונקציה.

Python

gcloud functions deploy hello_gcs \
--runtime python312 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.archive

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Python נתמכת להרצת הפונקציה.

המשך

gcloud functions deploy HelloGCS \
--runtime go121 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.archive

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Go נתמכת להרצת הפונקציה.

Java

gcloud functions deploy java-gcs-function \
--entry-point functions.HelloGcs \
--runtime java17 \
--memory 512MB \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.archive

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Java נתמכת להרצת הפונקציה.

Ruby

gcloud functions deploy hello_gcs --runtime ruby33 \
-
-trigger-resource YOUR_TRIGGER_BUCKET_NAME \
-
-trigger-event google.storage.object.archive

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Ruby נתמכת להרצת הפונקציה.

כאשר YOUR_TRIGGER_BUCKET_NAME הוא השם של הקטגוריה של Cloud Storage שמפעילה את הפונקציה.

ארכיון אובייקטים: הפעלת הפונקציה

כדי להפעיל את הפונקציה:

  1. יוצרים קובץ gcf-test.txt ריק בספרייה שבה נמצא הקוד לדוגמה.

  2. מוודאים שהפעלתם את ניהול הגרסאות בקטגוריה:

    gcloud storage buckets update gs://YOUR_TRIGGER_BUCKET_NAME --versioning
  3. מעלים את הקובץ ל-Cloud Storage:

    gcloud storage cp gcf-test.txt gs://YOUR_TRIGGER_BUCKET_NAME

    כאשר YOUR_TRIGGER_BUCKET_NAME הוא השם של הקטגוריה של Cloud Storage שאליה תעלו קובץ בדיקה. בשלב הזה, הפונקציה עדיין לא אמורה לפעול.

  4. מעבירים את הקובץ לארכיון כדי להפעיל את הפונקציה:

    gcloud storage rm gs://YOUR_TRIGGER_BUCKET_NAME/gcf-test.txt
  5. כדי לוודא שההפעלות הושלמו, בודקים את היומנים:

    gcloud functions logs read --limit 50
    

עדכון מטא-נתונים של אובייקט

אירועים של עדכון מטא-נתונים מופעלים כשמעדכנים את המטא-נתונים של אובייקט קיים.

עדכון המטא-נתונים של האובייקט: פריסת הפונקציה

באמצעות אותו קוד לדוגמה כמו בדוגמה של finalize, פורסים את הפונקציה עם עדכון המטא-נתונים כאירוע הטריגר. מריצים את הפקודה הבאה בספרייה שבה נמצא הקוד לדוגמה:

Node.js

gcloud functions deploy helloGCS \
--runtime nodejs22 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.metadataUpdate

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Node.js נתמכת להרצת הפונקציה.

Python

gcloud functions deploy hello_gcs \
--runtime python312 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.metadataUpdate

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Python נתמכת להרצת הפונקציה.

המשך

gcloud functions deploy HelloGCS \
--runtime go121 \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.metadataUpdate

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Go נתמכת להרצת הפונקציה.

Java

gcloud functions deploy java-gcs-function \
--entry-point functions.HelloGcs \
--runtime java17 \
--memory 512MB \
--trigger-resource YOUR_TRIGGER_BUCKET_NAME \
--trigger-event google.storage.object.metadataUpdate

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Java נתמכת להרצת הפונקציה.

Ruby

gcloud functions deploy hello_gcs --runtime ruby33 \
-
-trigger-resource YOUR_TRIGGER_BUCKET_NAME \
-
-trigger-event google.storage.object.metadataUpdate

משתמשים בדגל --runtime כדי לציין את מזהה סביבת זמן הריצה של גרסת Ruby נתמכת להרצת הפונקציה.

כאשר YOUR_TRIGGER_BUCKET_NAME הוא השם של הקטגוריה של Cloud Storage שמפעילה את הפונקציה.

עדכון המטא-נתונים של האובייקט: הפעלת הפונקציה

כדי להפעיל את הפונקציה:

  1. יוצרים קובץ gcf-test.txt ריק בספרייה שבה נמצא הקוד לדוגמה.

  2. מוודאים שהקטגוריה לא מוגדרת עם ניהול גרסאות:

    gcloud storage buckets update gs://YOUR_TRIGGER_BUCKET_NAME --no-versioning
  3. מעלים את הקובץ ל-Cloud Storage:

    gcloud storage cp gcf-test.txt gs://YOUR_TRIGGER_BUCKET_NAME

    כאשר YOUR_TRIGGER_BUCKET_NAME הוא השם של הקטגוריה של Cloud Storage שאליה תעלו קובץ בדיקה. בשלב הזה, הפונקציה עדיין לא אמורה לפעול.

  4. מעדכנים את המטא-נתונים של הקובץ:

    gcloud storage objects update gs://YOUR_TRIGGER_BUCKET_NAME/gcf-test.txt --content-type=text/plain
  5. כדי לוודא שההפעלות הושלמו, בודקים את היומנים:

    gcloud functions logs read --limit 50
    

הסרת המשאבים

כדי להימנע מחיובים בחשבון Google Cloud בגלל השימוש במשאבים שנעשה במסגרת המדריך הזה, אפשר למחוק את הפרויקט שמכיל את המשאבים, או להשאיר את הפרויקט ולמחוק את המשאבים הנפרדים.

מחיקת הפרויקט

הדרך הקלה ביותר לבטל את החיוב היא למחוק את הפרויקט שיצרתם בשביל המדריך.

כדי למחוק את הפרויקט:

  1. במסוף Google Cloud , נכנסים לדף Manage resources.

    כניסה לדף Manage resources

  2. ברשימת הפרויקטים, בוחרים את הפרויקט שרוצים למחוק ולוחצים על Delete.
  3. כדי למחוק את הפרויקט, כותבים את מזהה הפרויקט בתיבת הדו-שיח ולוחצים על Shut down.

מחיקת הפונקציה

מחיקה של פונקציות Cloud Run לא מסירה משאבים שמאוחסנים ב-Cloud Storage.

כדי למחוק את הפונקציה שיצרתם במדריך הזה, מריצים את הפקודה הבאה:

Node.js

gcloud functions delete helloGCS 

Python

gcloud functions delete hello_gcs 

Go

gcloud functions delete HelloGCS 

Java

gcloud functions delete java-gcs-function 

Ruby

gcloud functions delete hello_gcs 

אפשר גם למחוק פונקציות Cloud Run ממסוףGoogle Cloud .

המאמרים הבאים