[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-05 UTC。"],[],[],null,["# Migrate from Object change notifications to Pub/Sub notifications\n\nThis guide is for users of the Cloud Storage's deprecated [Object\nchange notifications](/storage/docs/object-change-notification) feature. [Pub/Sub notifications for\nCloud Storage](/storage/docs/pubsub-notifications) is the recommended tool\nfor generating notifications that track changes to objects in your\nCloud Storage buckets. Pub/Sub notifications offer\nimproved speed, flexibility, setup, and cost-effectiveness. This guide explains\nthe differences between Object change notifications and Pub/Sub\nnotifications for Cloud Storage and provides [migration steps](#migration-steps) from\nObject change notifications to Pub/Sub notifications.\n\nOverview of Object change notifications\n---------------------------------------\n\nObject change notifications are a legacy mechanism in Cloud Storage for\nnotifying an application about changes to objects within a bucket. When an\nObject change notification is set up, Cloud Storage sends HTTP POST\nrequests (webhooks) to a specified application URL whenever an object is added,\nupdated, or deleted. Object change notifications are established by sending a\n`watchAll` request to Cloud Storage, using the JSON API, client\nlibraries, or the gsutil notification `watchbucket` command. There is no `pull`\nmechanism, and you must have a publicly accessible domain name backed by an HTTP\nserver to receive the webhook messages. We recommend using Pub/Sub\nnotifications for Cloud Storage for new implementations due to its\nreliability, scalability, and flexibility.\n\nFor more detailed information, see [Object change\nnotification](/storage/docs/object-change-notification).\n\nOverview of Pub/Sub notifications\n---------------------------------\n\nPub/Sub notifications for Cloud Storage provide a modern,\nscalable, and reliable way to trigger actions in response to changes in your\nCloud Storage buckets by sending event information to a\nPub/Sub topic. Pub/Sub offers push-based delivery of\nmessages as HTTP POST requests to webhooks. When objects are created, updated,\nor deleted, Cloud Storage publishes messages containing object metadata\nto a specified Pub/Sub topic, which can then be consumed by\nvarious subscribers such as Cloud Run functions, data pipelines, or\nmicroservices, enabling flexible and event-driven architectures with\nat-least-once delivery and robust error handling features.\n\nFor more detailed information, see [Pub/Sub notifications for\nCloud Storage](/storage/docs/pubsub-notifications).\n\nCompare Object change notifications with Pub/Sub notifications\n--------------------------------------------------------------\n\nThe following table compares Object change notifications with\nPub/Sub notifications features:\n\nWhy migrate to Pub/Sub notifications?\n-------------------------------------\n\nMigrating from the legacy Object change notifications to Pub/Sub\nfor Cloud Storage notifications is an important step for robust event\nmanagement. Pub/Sub is recommended for event-driven architectures\nwithin Google Cloud, offering significant technical and operational\nadvantages over Object change notifications.\n\nThe following are the advantages of migrating to Pub/Sub\nnotifications:\n\n- **Reliable delivery**: Pub/Sub delivers each published message at least once for every subscription, validating that events reach your consumers. Reliable delivery minimizes data loss and improves the dependability of your workflows compared to Object change notifications less robust delivery model.\n- **Scalability**: Designed for high throughput, Pub/Sub notifications can handle large volumes of events automatically. Using Pub/Sub notifications, you can eliminate the performance bottlenecks you might encounter with Object change notifications as your data or event frequency increases.\n- **Integration with Google Cloud services**: Pub/Sub seamlessly integrates with multiple Google Cloud services, providing flexibility for building automated workflows using Cloud Run functions, Cloud Run, Dataflow, and enhanced observability through Cloud Logging and Cloud Monitoring.\n- **Granular control**: With Pub/Sub you can filter messages at the subscription level. This enables consumers to receive only relevant events, reducing unnecessary processing and network traffic.\n- **Platform support**: Pub/Sub notifications is the supported messaging service. Migrating helps you use a technology that receives ongoing enhancements, security updates, and comprehensive documentation, unlike the deprecated Object change notifications.\n\nMigration steps\n---------------\n\nBoth Object change notifications and Pub/Sub notifications for\nCloud Storage can occasionally send duplicate messages. Therefore, your\nconsuming code must be designed to safely handle duplicate messages.\n\nTo migrate from Object change notifications to Pub/Sub\nnotifications, follow these steps:\n\n1. Start using Pub/Sub notifications for Cloud Storage\n in addition to your existing Object change notifications setup. For\n information about how to configure Pub/Sub notifications, see\n [Configure Pub/Sub notifications for\n Cloud Storage](/storage/docs/pubsub-notifications).\n\n2. Test and verify that your application's Pub/Sub notifications\n processing workflow is functioning correctly. For information about how to\n monitor Pub/Sub subscription, see [Monitor subscriptions\n within Pub/Sub](/pubsub/docs/monitor-subscription).\n\n3. Stop processing messages received from an Object change notifications\n channel. To stop a notifications channel, make a\n [stop](/storage/docs/object-change-notification#_Stop) request.\n\nConsiderations for Pub/Sub push subscription\n--------------------------------------------\n\nWhile [Pub/Sub pull subscriptions](/pubsub/docs/pull) offer enhanced flexibility and\ncontrol, [Pub/Sub push subscriptions](/pubsub/docs/push) closely resemble Object change\nnotification messages. As a result, the push subscriptions become a faster migration path for\nexisting Object change notification users. For a detailed comparison of push and\npull subscriptions, see [Choose a subscription type](/pubsub/docs/subscriber).\n\nIf you plan to use push subscription and similarly plan to reuse existing\nnotification handling code, you'll need to consider the differences between\nObject change notifications and Pub/Sub notifications push request\nformats and response code interpretations. The differences are described in the\nfollowing sections.\n\n### Push request format\n\nThis section describes the push request format differences between Object change\nnotifications and Pub/Sub notifications.\n\n- **Object change notifications**: An Object change notification is delivered\n as an HTTP POST request to your application URL, in the following format:\n\n ```\n POST /ApplicationUrlPath\n Accept: * / *\n Content-Length: 1097\n Content-Type: application/json; charset=\"utf-8\"\n Host: ApplicationUrlHost\n X-Goog-Channel-Id: ChannelId\n X-Goog-Channel-Token: ClientToken\n X-Goog-Resource-Id: ResourceId\n X-Goog-Resource-State: ResourceState\n X-Goog-Resource-Uri: https://storage.googleapis.com/storage/v1/b/BucketName/o?alt=json\n\n {\n \"kind\": \"storage#object\",\n \"id\": \"BucketName/ObjectName\",\n \"selfLink\": \"https://www.googleapis.com/storage/v1/b/BucketName/o/ObjectName\",\n \"name\": \"ObjectName\",\n \"bucket\": \"BucketName\",\n \"generation\": \"1367014943964000\",\n \"metageneration\": \"1\",\n \"contentType\": \"application/octet-stream\",\n \"updated\": \"2013-04-26T22:22:23.832Z\",\n \"size\": \"10\",\n \"md5Hash\": \"xHZY0QLVuYng2gnOQD90Yw==\",\n \"mediaLink\": \"https://content-storage.googleapis.com/storage/v1/b/BucketName/o/ObjectName?generation=1367014943964000&alt=media\",\n \"owner\": {\n \"entity\": \"user-jeffersonloveshiking@gmail.com\"\n },\n \"crc32c\": \"C7+82w==\",\n \"etag\": \"COD2jMGv6bYCEAE=\"\n }\n ```\n- **Pub/Sub notifications** : A Pub/Sub\n notification, when configured for push delivery, is delivered as an HTTP\n POST request. The `data` field contains the base64-encoded\n Cloud Storage event payload. When the data field is decoded, it\n matches the Object change notifications message body.\n\n ```\n POST /YourSpecifiedURL\n Accept: * / *\n Content-Length: 1097\n Content-Type: application/json; charset=\"utf-8\"\n Host: ApplicationUrlHost\n {\n \"deliveryAttempt\": 5,\n \"message\":\n {\"attributes\":\n {\"notificationConfig\":\"projects/_/buckets/foo/notificationConfigs/3\",\n \"eventType\": \"OBJECT_FINALIZE\",\n \"payloadFormat\": \"JSON_API_V1\",\n \"bucketId\": \"foo\",\n \"objectId\": \"bar\",\n \"objectGeneration\": 123456,\n \"eventTime\": \"2021-01-15T01:30:15.01Z\"\n },\n \"data\": \"ewogImtpbm\",\n \"messageId\": \"2070443601311540\",\n \"message_id\": \"2070443601311540\",\n \"orderingKey\": \"key\",\n \"publishTime\": \"2021-02-26T19:13:55.749Z\",\n \"publish_time\": \"2021-02-26T19:13:55.749Z\"\n },\n \"subscription\": \"projects/myproject/subscriptions/mysubscription\"\n }\n ```\n\n### Response code\n\nThe following table describes the response code interpretation differences\nbetween Object change notifications and Pub/Sub notifications:\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\n- [Configure Pub/Sub notifications for Cloud Storage](/storage/docs/reporting-changes).\n- [Learn more about Pub/Sub](/pubsub/docs/overview).\n- [Subscribe a bucket](/pubsub/docs/create-cloudstorage-subscription) to receive notifications sent to Pub/Sub."]]