[[["易于理解","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-08-27。"],[],[],null,["# Deploy Service Extensions plugins in Media CDN routes\n\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes how to Deploy Service Extensions plugins in\nMedia CDN routes.\n\nYou can use Media CDN with Service Extensions\nto add custom code to the request-response processing path. Such customization\nunlocks a wide variety of lightweight use cases.\n\nFor more information about Service Extensions concepts, see\n[Service Extensions overview](/service-extensions/docs/overview).\n\nBefore you begin\n----------------\n\n1. [Create a Media CDN origin](/media-cdn/docs/quickstart#create-origin).\n2. [Create a Media CDN service](/media-cdn/docs/quickstart#create-service).\n3. [Create a plugin by using Service Extensions](/service-extensions/docs/create-plugin).\n\nDeploy a Service Extensions plugin in a Media CDN route\n-------------------------------------------------------\n\nTo deploy a Service Extensions plugin in a Media CDN\nroute, follow these steps:\n\n1. To export the current configuration of your service to a YAML file, run\n the [`gcloud edge-cache services export` command](/sdk/gcloud/reference/edge-cache/services/export):\n\n gcloud edge-cache services export \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eSERVICE_NAME\u003c/span\u003e\u003c/var\u003e \\\n --destination=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eFILENAME\u003c/span\u003e\u003c/var\u003e.yaml\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e: the name of the Media CDN service\n - \u003cvar translate=\"no\"\u003eFILENAME\u003c/var\u003e: the name of the YAML file\n2. In Cloud Shell, use a text editor to edit the YAML file.\n\n3. Update the routes in the file to add the `wasmAction` header as shown in\n the following example:\n\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSERVICE_NAME\u003c/span\u003e\u003c/var\u003e\n routing:\n hostRules:\n - hosts:\n - \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDOMAIN_NAME\u003c/span\u003e\u003cspan class=\"devsite-syntax-w\"\u003e \u003c/span\u003e\u003c/var\u003e\n pathMatcher: routes\n pathMatchers:\n - name: routes\n routeRules:\n - priority: '1'\n description: Route 1\n matchRules:\n - prefixMatch: /plugins\n origin: projects/\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e/locations/global/edgeCacheOrigins/\u003cvar translate=\"no\"\u003eORIGIN_NAME\u003c/var\u003e\n routeAction:\n wasmAction: projects/\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e/locations/global/wasmActions/\u003cvar translate=\"no\"\u003eWASM_ACTION\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e: the name of the Media CDN service\n - \u003cvar translate=\"no\"\u003eDOMAIN_NAME\u003c/var\u003e: the domain of the Media CDN service\n - \u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e: the [project number](/resource-manager/docs/creating-managing-projects#identifying_projects)\n - \u003cvar translate=\"no\"\u003eORIGIN_NAME\u003c/var\u003e: the origin for the content\n - \u003cvar translate=\"no\"\u003eWASM_ACTION\u003c/var\u003e: the Service Extensions WASM action\n4. Save the YAML file.\n\n5. Run the [`gcloud edge-cache services import` command](/sdk/gcloud/reference/edge-cache/services/import):\n\n gcloud edge-cache services import \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nn\"\u003eSERVICE_NAME\u003c/span\u003e\u003c/var\u003e \\\n --source=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eFILENAME\u003c/span\u003e\u003c/var\u003e.yaml\n\n| **Note:** Service Extensions plugins run after all other configurable features of Media CDN are executed.\n\nWhat's next\n-----------\n\n- Learn more about [Service Extensions](/service-extensions/docs/overview) concepts.\n- Learn how to [prepare and upload the files required](/service-extensions/docs/access-control) to create plugins by using Service Extensions.\n- Learn how to [create a plugin](/service-extensions/docs/create-plugin)."]]