您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

设置 Azure 应用服务中的过渡环境Set up staging environments in Azure App Service

备注

本操作指南介绍了如何使用新的预览管理页面管理槽。This how-to guide shows how to manage slots using a new preview management page. 习惯于现有管理页面的客户可以像以前一样继续使用现有的槽管理页面。Customers used to the existing management page can continue to use the existing slot management page as before.

将 Web 应用、Linux 上的 Web 应用、移动后端和 API 应用部署到应用服务时,如果应用在“标准” 、“高级” 或“独立” 应用服务计划层中运行,则可以部署到单独的部署槽而不是默认的生产槽。When you deploy your web app, web app on Linux, mobile back end, and API app to App Service, you can deploy to a separate deployment slot instead of the default production slot when running in the Standard, Premium, or Isolated App Service plan tier. 部署槽实际上是具有自身主机名的实时应用。Deployment slots are actually live apps with their own hostnames. 两个部署槽(包括生产槽)之间的应用内容与配置元素可以交换。App content and configurations elements can be swapped between two deployment slots, including the production slot. 将应用程序部署到非生产槽具有以下优点:Deploying your application to a non-production slot has the following benefits:

  • 可以在分阶段部署槽中验证应用更改,然后将其与生产槽交换。You can validate app changes in a staging deployment slot before swapping it with the production slot.
  • 首先将应用部署到槽,然后将其交换到生产,这确保槽的所有实例都已准备好,然后交换到生产。Deploying an app to a slot first and swapping it into production makes sure that all instances of the slot are warmed up before being swapped into production. 部署应用时,这样可避免停机。This eliminates downtime when you deploy your app. 流量重定向是无缝的,且不会因交换操作而删除任何请求。The traffic redirection is seamless, and no requests are dropped because of swap operations. 当不需要预交换验证时,可以通过配置自动交换来自动化这整个工作流。This entire workflow can be automated by configuring Auto Swap when pre-swap validation isn't needed.
  • 交换后,具有以前分阶段应用的槽现在具有以前的生产应用。After a swap, the slot with previously staged app now has the previous production app. 如果交换到生产槽的更改与预期不同,可以立即执行同一交换来收回“上一已知的良好站点”。If the changes swapped into the production slot aren't as you expect, you can perform the same swap immediately to get your "last known good site" back.

每种应用服务计划层支持不同数量的部署槽。Each App Service plan tier supports a different number of deployment slots. 若要了解应用层支持的槽数,请参阅应用服务限制To find out the number of slots your app's tier supports, see App Service Limits. 若要将应用缩放到其他层,目标层必须支持应用业已使用的槽数。To scale your app to a different tier, the target tier must support the number of slots your app already uses. 例如,如果应用有 5 个以上的槽位,则不能向下缩放到“标准”层,因为“标准”层只支持 5 个部署槽位 。For example, if your app has more than five slots, you can't scale it down to Standard tier, because Standard tier only supports five deployment slots.

添加槽Add slot

应用必须在“标准”、“高级”或“独立”层中运行,才能启用多个部署槽位 。The app must be running in the Standard, Premium, or Isolated tier in order for you to enable multiple deployment slots.

  1. Azure 门户中,打开应用的资源页In the Azure portal, open your app's resource page.

  2. 在左侧导航栏中,选择“部署槽位(预览)”选项,然后单击“添加槽” 。In the left navigation, choose the Deployment slots (Preview) option, then click Add Slot.

    添加新部署槽

    备注

    如果应用尚未处于“标准”、“高级”或“独立”层,则会收到消息,指示启用分步发布支持的层 。If the app isn't already in the Standard, Premium, or Isolated tier, you receive a message indicating the supported tiers for enabling staged publishing. 此时,可选择“升级” ,并导航到应用的“缩放” 选项卡,并继续。At this point, you have the option to select Upgrade and navigate to the Scale tab of your app before continuing.

  3. 在“添加槽”对话框中,为槽提供一个名称,并选择是否要从其他现有部署槽位中克隆应用配置 。In the Add a slot dialog, give the slot a name, and select whether to clone app configuration from another existing deployment slot. 单击“添加”以继续 。Click Add to continue.

    配置源

    可以从任何现有槽克隆配置。You can clone configuration from any existing slot. 可以克隆的设置包括应用设置、连接字符串、语言框架版本、Web 套接字、HTTP 版本和平台位数。Settings that can be cloned include app settings, connection strings, language framework versions, web sockets, HTTP version, and platform bitness.

  4. 添加槽后,单击“关闭”以关闭对话框 。After the slot is added, click Close to close the dialog. 新槽现在显示在“部署槽位(预览)”页面中 。The new slot is now shown in the Deployment slots (Preview) page. 默认情况下,新槽的“流量 %”设置为 0,所有客户流量都路由到生产槽 。By default, the Traffic % is set to 0 for the new slot, with all customer traffic routed to the production slot.

  5. 单击新部署槽位打开该槽的资源页。Click the new deployment slot to open that slot's resource page.

    部署槽标题

    过渡槽具有管理页面,就像任何其他应用服务应用一样。The staging slot has a management page just like any other App Service app. 可以更改此槽的配置。You can change the slot's configuration. 槽的名称将出现在页面顶部,提醒你正在查看部署槽位。The name of the slot is shown at the top of the page to remind you that you're viewing the deployment slot.

  6. 单击此槽资源页中的应用 URL。Click the app URL in the slot's resource page. 部署槽位有其自己的主机名,同时也是动态应用。The deployment slot has its own hostname and is also a live app. 若要限制对部署槽位的公共访问权限,请参阅 Azure 应用服务 IP 限制To limit public access to the deployment slot, see Azure App Service IP Restrictions.

即使从其他槽克隆设置,新部署槽位也无内容。The new deployment slot has no content, even if you clone the settings from a different slot. 例如,可以使用 git 发布到此槽For example, you can publish to this slot with git. 可以从其他存储库分支或不同的存储库部署到槽。You can deploy to the slot from a different repository branch or a different repository.

交换哪些设置?Which settings are swapped?

从另一个部署槽克隆配置时,可以编辑克隆的配置。When you clone configuration from another deployment slot, the cloned configuration is editable. 此外,某些配置元素在交换时遵循内容(不特定于槽位),而其他配置元素会在交换之后保留在同一个槽(特定于槽)。Furthermore, some configuration elements follow the content across a swap (not slot specific) while other configuration elements stay in the same slot after a swap (slot specific). 以下列表显示交换槽时会更改的设置。The following lists show the settings that change when you swap slots.

已交换的设置Settings that are swapped:

  • 常规设置 - 例如 Framework 版本、32/64 位、Web 套接字General settings - such as framework version, 32/64-bit, Web sockets
  • 应用设置(可以配置为停在槽中)App settings (can be configured to stick to a slot)
  • 连接字符串(可以配置为停在槽中)Connection strings (can be configured to stick to a slot)
  • 处理程序映射Handler mappings
  • 监视和诊断设置Monitoring and diagnostic settings
  • 公用证书Public certificates
  • WebJobs 内容WebJobs content
  • 混合连接 *Hybrid connections *
  • VNet 集成 *VNet integration *
  • 服务终结点 *Service Endpoints *
  • Azure CDN *Azure CDN *

功能标有 * 计划进行粘到槽。Features marked with a * are planned to be made sticky to the slot.

不交换的设置Settings that aren't swapped:

  • 发布终结点Publishing endpoints
  • 自定义域名Custom Domain Names
  • 私有证书和 SSL 绑定Private certificates and SSL bindings
  • 缩放设置Scale settings
  • Web 作业计划程序WebJobs schedulers
  • IP 限制IP restrictions
  • AlwaysOnAlways On
  • 协议设置 (HTTPS,TLS 版本,客户端证书)Protocol Settings (HTTPS, TLS version, client certificates)
  • 诊断日志设置Diagnostic log settings
  • CORSCORS

要将应用设置或连接字符串配置为固定在某个特定槽中(不交换),请导航到该槽的“应用程序设置”页面,然后针对应固定在该槽中的配置元素选中“槽设置”框 。To configure an app setting or connection string to stick to a specific slot (not swapped), navigate to the Application settings page for that slot, then select the Slot Setting box for the configuration elements that should stick to the slot. 将配置元素标记为特定于槽将告知应用服务其不可交换。Marking a configuration element as slot specific tells App Service that it's not swappable.

槽设置

交换两个槽Swap two slots

可以在应用的“部署槽位(预览)”页面中交换部署槽位 。You can swap deployment slots in your app's Deployment slots (Preview) page.

还可以从“概述”和“部署槽位”页面交换槽,但目前它仍提供旧体验 。You can also swap slots from the Overview and Deployment slots pages, but currently it gives you the old experience. 本指南向我们展示了如何在“部署槽位(预览)”页面中使用新用户界面 。This guide shows us how to use the new user interface in the Deployment slots (Preview) page.

重要

将应用从部署槽位交换到生产之前,请确保所有设置已完全根据希望它在交换目标中的位置明确地进行配置。Before you swap an app from a deployment slot into production, make sure that all settings are configured exactly as you want to have it in the swap target.

若要交换部署槽位,请按照下列步骤进行操作:To swap deployment slots, follow these steps:

  1. 导航到应用的“部署槽位(预览)”页面,然后单击“交换” 。Navigate to your app's Deployment slots (Preview) page and click Swap.

    “交换”按钮

    “交换”对话框显示将要更改的所选源和目标槽位中的设置 。The Swap dialog shows settings in the selected source and target slots that will be changed.

  2. 选择所需的“源”和“目标”槽 。Select the desired Source and Target slots. 目标通常是生产槽。Usually, the target is the production slot. 此外,单击“源更改”和“目标更改”选项卡,并验证配置更改是否符合预期 。Also, click the Source Changes and Target Changes tabs and verify that the configuration changes are expected. 完成后,可以通过单击“交换”立即交换槽 。When finished, you can swap the slots immediately by clicking Swap.

    完成交换

    若要在交换实际发生之前查看目标槽如何使用新设置运行,不要单击“交换”,请按照交换预览中的说明进行操作 。To see how your target slot would run with the new settings before the swap actually happens, don't click Swap, but follow the instructions in Swap with preview.

  3. 完成后,单击“关闭”关闭对话框 。When you're finished, close the dialog by clicking Close.

带预览的交换(多阶段交换)Swap with preview (multi-phase swap)

备注

Linux 上的 Web 应用不支持带预览的交换。Swap with preview isn't supported in web apps on Linux.

在作为目标槽交换到生产环境之前,请在交换发生之前用交换的设置验证应用的运行。Before swapping into production as the target slot, validate the app runs with the swapped settings before the swap happens. 源槽在交换完成之前也已预热,这对于任务关键型应用程序也是可行的。The source slot is also warmed up before the swap completion, which is also desirable for mission-critical applications.

使用预览执行交换时,应用服务会在开始交换时执行以下操作:When you perform a swap with preview, App Service does the following when you start the swap:

  • 目标槽保持不变,该槽上的现有工作负荷(如生产)不会受影响。Keeps the target slot unchanged so existing workload on that slot (such as production) isn't affected.
  • 将目标槽的配置元素应用到源槽,包括特定于槽的连接字符串和应用设置。Applies the configuration elements of the target slot to the source slot, including the slot-specific connection strings and app settings.
  • 使用这些配置元素,重启源槽上的工作进程。Restarts the worker processes on the source slot using these configuration elements. 可以浏览源槽并查看运行配置更改的应用。You can browse the source slot and see the app run with the configuration changes.

如果在单独的步骤中完成交换,应用服务会将预热的源槽移动到目标槽中,并将目标槽移动到源槽中。If you complete the swap in a separate step, App Service moves the warmed-up source slot into the target slot, and the target slot into the source slot. 如果取消交换,应用服务会重新将源槽的配置元素应用到源槽。If you cancel the swap, App Service reapplies the configuration elements of the source slot to the source slot.

若要与预览交换,请按照下列步骤进行操作。To swap with preview, follow these steps.

  1. 按照交换部署槽位中的步骤进行操作,但请选择“使用预览执行交换” 。follow the steps in Swap deployment slots but select Perform swap with preview.

    带预览的交换

    该对话框显示源槽中的配置在阶段 1 中的更改方式,以及源槽和目标槽在阶段 2 中的更改方式。The dialog shows you how the configuration in the source slot changes in phase 1, and how the source and target slot change in phase 2.

  2. 准备好启动交换后,单击“开始交换” 。When ready to start the swap, click Start Swap.

    第 1 阶段完成后,将在对话框中收到通知。When phase 1 completes, you're notified in the dialog. 通过导航到 https://<app_name>-<source-slot-name>.azurewebsites.net 来预览源槽中的交换。Preview the swap in the source slot by navigating to https://<app_name>-<source-slot-name>.azurewebsites.net.

  3. 准备完成挂起的交换后,在“交换操作”中选择“完成交换”,然后单击“完成交换” 。When ready to complete the pending swap, select Complete Swap in Swap action and click Complete Swap.

    若要取消挂起的交换,请选择“取消交换”,然后单击“取消交换” 。To cancel a pending swap, select Cancel Swap instead and click Cancel Swap.

  4. 完成后,单击“关闭”关闭对话框 。When you're finished, close the dialog by clicking Close.

若要自动执行多阶段交换,请参阅“使用 PowerShell 进行自动化操作”。To automate a multi-phase swap, see Automate with PowerShell.

回滚交换Roll back swap

如果在槽交换后目标槽(例如,生产槽)中发生任何错误,请通过立即交换相同的两个槽以将槽恢复到其交换前状态。If any errors occur in the target slot (for example, the production slot) after a slot swap, restore the slots to their pre-swap states by swapping the same two slots immediately.

配置自动交换Configure Auto Swap

备注

Linux 上的 Web 应用中不支持自动交换。Auto Swap isn't supported in web apps on Linux.

自动交换简化了 DevOps 方案,在此方案中,可连续部署应用,无需冷启动且不会给应用的最终客户造成停机。Auto Swap streamlines DevOps scenarios where you want to deploy your app continuously with zero cold start and zero downtime for end customers of the app. 当槽自动交换到生产环境时,每次将代码更改推送到该槽时,应用服务会在源槽中预热后自动将应用交换到生产环境中。When a slot autoswaps into production, every time you push your code changes to that slot, App Service automatically swaps the app into production after it's warmed up in the source slot.

备注

在为生产槽配置自动交换之前,请考虑首先在非生产目标槽上测试自动交换。Before configuring Auto Swap for the production slot, consider testing Auto Swap on a non-production target slot first.

若要配置自动交换,请按照下列步骤进行操作:To configure Auto Swap, follow these steps:

  1. 导航到应用的资源页。Navigate to your app's resource page. 选择“部署槽位(预览)” > “<所需的源槽>” > “应用设置” 。Select Deployment slots (Preview) > <desired source slot> > Application settings.

  2. 在“自动交换”中,选择“打开”,在“自动交换槽”中选择所需的目标槽,并在命令栏中单击“保存” 。In Auto Swap, select On, then select the desired target slot in Auto Swap Slot, and click Save in the command bar.

  3. 执行代码推送到源槽。Execute a code push to the source slot. 不久之后,自动交换就会发生,而更新将反映在目标槽的 URL 上。Auto Swap happens after a short time and the update is reflected at your target slot's URL.

自定义预热Custom warm-up

使用自动交换时,某些应用可能需要在交换前自定义的预热操作。When using Auto-Swap, some apps may require custom warm-up actions before the swap. web.config 中的 applicationInitialization 配置元素允许指定要执行的自定义初始化操作。The applicationInitialization configuration element in web.config lets you specify custom initialization actions to be performed. 交换操作在与目标槽交换之前等待此自定义预热操作完成。The swap operation waits for this custom warm-up to complete before swapping with the target slot. 以下是 web.config 片段的示例。Here is a sample web.config fragment.

<system.webServer>
    <applicationInitialization>
        <add initializationPage="/" hostName="[app hostname]" />
        <add initializationPage="/Home/About" hostName="[app hostname]" />
    </applicationInitialization>
</system.webServer>

有关自定义 applicationInitialization 元素的详细信息,请参阅最常见的部署槽位交换故障以及如何修复它们For more information on customizing the applicationInitialization element, see Most common deployment slot swap failures and how to fix them.

还可以使用下列应用设置中的一个或多个来自定义预热行为:You can also customize the warm-up behavior with one or more of the following app settings:

  • WEBSITE_SWAP_WARMUP_PING_PATH:用于对你的站点进行预热的 ping 路径。WEBSITE_SWAP_WARMUP_PING_PATH: The path to ping to warmup your site. 通过指定以斜杠开头的自定义路径作为值来添加此应用设置。Add this app setting by specifying a custom path that begins with a slash as the value. 例如,/statuscheckFor example, /statuscheck. 默认值为 /The default value is /.
  • WEBSITE_SWAP_WARMUP_PING_STATUSES:预热操作的有效 HTTP 响应代码。WEBSITE_SWAP_WARMUP_PING_STATUSES: Valid HTTP response codes for the warm-up operation. 使用以逗号分隔的 HTTP 代码列表添加此应用设置。Add this app setting with a comma-separated list of HTTP codes. 例如:200,202For example: 200,202 . 如果返回的状态代码不在列表中,则预热和交换操作会停止。If the returned status code is not in the list, the warmup and swap operations are stopped. 默认情况下,所有响应代码都是有效的。By default, all response codes are valid.

监视器交换Monitor swap

如果交换操作需要很长时间才能完成,则可以在活动日志中获取有关交换操作的信息。If the swap operation takes a long time to complete, you can get information on the swap operation in the activity log.

在门户的应用资源页的左侧导航中,选择“活动日志” 。In your app's resource page in the portal, in the left-hand navigation, select Activity log.

交换操作在日志查询中显示为 Swap Web App SlotsA swap operation appears in the log query as Swap Web App Slots. 可以将其展开,然后选择一个子操作或错误来查看详细信息。You can expand it and select one of the suboperations or errors to see the details.

路由流量Route traffic

默认情况下,应用生产 URL (http://<app_name>.azurewebsites.net) 的所有客户端请求都将路由到生产槽。By default, all client requests to the app's production URL (http://<app_name>.azurewebsites.net) are routed to the production slot. 可以将部分流量路由到另一个槽。You can route a portion of the traffic to another slot. 如果需要用户对新更新的反馈,但是还没有准备好将其发布到生产环境中,那么这个功能非常有用。This feature is useful if you need user feedback for a new update, but you're not ready to release it to production.

自动路由生产流量Route production traffic automatically

若要自动路由生产流量,请按照下列步骤进行操作:To route production traffic automatically, follow these steps:

  1. 导航到应用的资源页,然后选择“部署槽位(预览)” 。Navigate to your app's resource page and select Deployment slots (Preview).

  2. 在要路由到的槽的“流量 %”列中,指定一个百分比(介于 0 到 100 之间)以表示要路由的总流量 。In the Traffic % column of the slot you want to route to, specify a percentage (between 0 and 100) to represent the amount of total traffic you want to route. 单击“ 保存”。Click Save.

保存设置后,指定百分比的客户端将随机路由到非生产槽。Once the setting is saved, the specified percentage of clients is randomly routed to the non-production slot.

客户端自动路由到特定槽后,在该客户端会话生存期内都将“固定”到该槽。Once a client is automatically routed to a specific slot, it's "pinned" to that slot for the life of that client session. 在客户端浏览器上,可以通过查看 HTTP 标头中的 x-ms-routing-name cookie 来查看会话固定到哪个槽。On the client browser, you can see which slot your session is pinned to by looking at the x-ms-routing-name cookie in your HTTP headers. 路由到“暂存”槽的请求具有 cookie x-ms-routing-name=stagingA request that's routed to the "staging" slot has the cookie x-ms-routing-name=staging. 路由到生产槽的请求具有 cookie x-ms-routing-name=selfA request that's routed to the production slot has the cookie x-ms-routing-name=self.

手动路由生产流量Route production traffic manually

除了自动流量路由以外,应用服务也可以将请求路由到特定槽。In addition to automatic traffic routing, App Service can route requests to a specific slot. 如果想要让用户能够选择加入或退出 beta 应用,这就非常有用。This is useful when you want your users to be able to opt-into or opt-out of your beta app. 若要手动路由生产流量,请使用 x-ms-routing-name 查询参数。To route production traffic manually, you use the x-ms-routing-name query parameter.

例如,要让用户选择退出 beta 应用,可以在网页中插入以下链接:To let users opt out of your beta app, for example, you can put this link in your web page:

<a href="<webappname>.azurewebsites.net/?x-ms-routing-name=self">Go back to production app</a>

字符串 x-ms-routing-name=self 指定生产槽。The string x-ms-routing-name=self specifies the production slot. 客户端浏览器访问此链接后,不仅浏览器会重定向到生产槽,后续每个请求也都具有将会话固定到生产槽的 x-ms-routing-name=self cookie。Once the client browser accesses the link, not only is it redirected to the production slot, but every subsequent request has the x-ms-routing-name=self cookie that pins the session to the production slot.

要让用户选择加入 beta 应用,请将相同的查询参数设置为非生产槽的名称,例如:To let users opt in to your beta app, set the same query parameter to the name of the non-production slot, for example:

<webappname>.azurewebsites.net/?x-ms-routing-name=staging

默认情况下,新的槽提供的路由规则0%,它们以灰色显示。By default, new slots are given a routing rule of 0%, shown in grey. 通过显式将此值设置为0%(以黑色文本显示),用户可通过使用手动访问过渡槽x-ms-routing-name查询参数,但它们不会路由到的槽自动由于路由百分比设置为 0。By explicitly setting this value to 0% (shown in black text), your users can access the staging slot manually by using the x-ms-routing-name query parameter, but they will not be routed to the slot automatically since the routing percentage is set to 0. 这是一种高级的方案,其中您可以"隐藏"来自公共过渡槽,同时允许内部团队要测试的槽的更改。This is an advanced scenario where you can "hide" your staging slot from the public while allowing internal teams to test changes on the slot.

删除槽Delete slot

导航到应用的资源页。Navigate to your app's resource page. 选择“部署槽位(预览)” > “<删除槽>” > “概述” 。Select Deployment slots (Preview) > <slot to delete> > Overview. 在命令栏中,单击“删除” 。Click Delete in the command bar.

删除部署槽

使用 PowerShell 进行自动化操作Automate with PowerShell

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

Azure PowerShell 是一个模块,可提供通过 Windows PowerShell 管理 Azure 的 cmdlet,包括对管理 Azure 应用服务的部署槽的支持。Azure PowerShell is a module that provides cmdlets to manage Azure through Windows PowerShell, including support for managing deployment slots in Azure App Service.

有关安装和配置 Azure PowerShell 的信息以及使用 Azure 订阅对 Azure PowerShell 进行身份验证的信息,请参阅如何安装和配置 Microsoft Azure PowerShellFor information on installing and configuring Azure PowerShell, and on authenticating Azure PowerShell with your Azure subscription, see How to install and configure Microsoft Azure PowerShell.


创建 Web 应用Create web app

New-AzWebApp -ResourceGroupName [resource group name] -Name [app name] -Location [location] -AppServicePlan [app service plan name]

创建槽Create slot

New-AzWebAppSlot -ResourceGroupName [resource group name] -Name [app name] -Slot [deployment slot name] -AppServicePlan [app service plan name]

启动带预览的交换(多阶段交换)并将目标槽配置应用到源槽Initiate swap with preview (multi-phase swap) and apply destination slot configuration to source slot

$ParametersObject = @{targetSlot  = "[slot name – e.g. “production”]"}
Invoke-AzResourceAction -ResourceGroupName [resource group name] -ResourceType Microsoft.Web/sites/slots -ResourceName [app name]/[slot name] -Action applySlotConfig -Parameters $ParametersObject -ApiVersion 2015-07-01

取消挂起的交换(带预览的交换)并还原源槽配置Cancel pending swap (swap with review) and restore source slot configuration

Invoke-AzResourceAction -ResourceGroupName [resource group name] -ResourceType Microsoft.Web/sites/slots -ResourceName [app name]/[slot name] -Action resetSlotConfig -ApiVersion 2015-07-01

交换部署槽Swap deployment slots

$ParametersObject = @{targetSlot  = "[slot name – e.g. “production”]"}
Invoke-AzResourceAction -ResourceGroupName [resource group name] -ResourceType Microsoft.Web/sites/slots -ResourceName [app name]/[slot name] -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-07-01

在活动日志中监视交换事件Monitor swap events in the activity Log

Get-AzLog -ResourceGroup [resource group name] -StartTime 2018-03-07 -Caller SlotSwapJobProcessor  

删除槽Delete slot

Remove-AzResource -ResourceGroupName [resource group name] -ResourceType Microsoft.Web/sites/slots –Name [app name]/[slot name] -ApiVersion 2015-07-01

使用 CLI 进行自动化Automate with CLI

有关用于部署槽的 Azure CLI 命令,请参阅 az webapp deployment slotFor Azure CLI commands for deployment slots, see az webapp deployment slot.

后续步骤Next steps

阻止对非生产槽进行访问Block access to non-production slots