自动执行开发人员门户部署Automate developer portal deployments

API 管理开发人员门户支持以编程方式访问内容。The API Management developer portal supports programmatic access to content. 它允许你通过内容管理 REST API 将数据导入或导出 API 管理服务。It allows you to import data to or export from an API Management service through the content management REST API. REST API 访问适用于托管门户和自承载门户。The REST API access works for both managed and self-hosted portals.

自动迁移脚本Automated migration script

可以使用 API 在两个 API 管理服务之间自动迁移内容(例如,测试环境中的服务和生产环境中的服务)。You can use the API to automate migration of content between two API Management services - for example, a service in the test environment and a service in the production environment. API 管理开发人员门户 GitHub 存储库中的 scripts.v3/migrate.js 脚本可简化此自动化过程。The scripts.v3/migrate.js script in the API Management developer portal GitHub repo simplifies this automation process.

警告

该脚本会删除目标 API 管理服务中的开发人员门户内容。The script removes contents of the developer portal in your destination API Management service. 如果你担心,请确保执行备份。If you're concerned about it, make sure you perform a backup.

备注

如果使用自承载门户,并且具有显式定义的自定义存储帐户来承载媒体文件(例如,在 config.design.json 配置文件中定义 blobStorageUrl 设置),则需要使用原始 scripts/migrate.js 脚本If you're using a self-hosted portal with an explicitly defined custom storage account to host media files (i.e., you define the blobStorageUrl setting in the config.design.json configuration file), you need to use the original scripts/migrate.js script. 原始脚本不适用于具有由 API 管理托管的媒体存储帐户的托管门户或自承载门户。The original script doesn't work for managed or self-hosted portals with the media storage account managed by API Management. 在这种情况下,请改用 /scripts.v3 文件夹中的脚本。In that case, use the script from the /scripts.v3 folder instead.

此脚本执行以下步骤:The script performs the following steps:

  1. 从源 API 管理服务捕获门户内容和媒体。Capture the portal content and media from the source API Management service.
  2. 从目标 API 管理服务删除门户内容和媒体。Remove the portal content and media from the destination API Management service.
  3. 将门户内容和媒体上传到目标 API 管理服务。Upload the portal content and media to the destination API Management service.
  4. 可选并且仅适用于托管门户 - 自动发布门户。Optionally and for managed portals only - automatically publish the portal.

成功执行脚本后,目标 API 管理服务应包含与源服务相同的门户内容,你能够以管理员身份查看它。After the script is successfully executed, the target API Management service should contain the same portal content as the source service and you'll be able to see it as an administrator.

  • 如果使用的是托管门户,则可以将脚本设置为自动发布目标门户,以使迁移后的版本自动提供给访问者。If you're using a managed portal, you can set the script to auto-publish the destination portal to make the migrated version automatically available to the visitors.
  • 如果使用的是自承载门户,则需要手动发布目标门户。If you're using a self-hosted portal, you need to publish the destination portal manually. 按照本教程中的发布和承载说明来设置自承载开发人员门户Follow the publishing and hosting instructions in the tutorial to set up a self-hosted developer portal.

后续步骤Next steps

详细了解开发人员门户:Learn more about the developer portal: