Allow app service diagnostic log settings to be sticky to Deployment Slots We just migrated from a classic cloud service to a website (app service). But it turns out that we MUST enable the same exact logging settings on our STAGING slot because otherwise when we do a swap the PRODUCTION slot ends up with no logging! About Deployment Slots Azure web app service has a fantastic feature called 'Deployment Slots', available on standard or premium mode pricing tiers. This feature allows you to spin up multiple slots (full instances) of your web application for test/development and staging uses. What's great about using deployment slots? First - you can test changes to your. Jun 15, 2011  Windows Azure, Windows 8, Cloud Computing, Big Data and Hadoop: All together at one place. One problem, One solution at One time How to SWAP VIP from Staging to Production using Power Shell Script.

-->

Syntax

Description

The Switch-AzureRmWebAppSlot switches two slots associated with an Azure Web App.

Examples

Example 1

This command will switch slot 'sourceslot' slot with 'destinationslot' for Web App ContosoWebApp associated with the resource group Default-Web-WestUS

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

The credentials, account, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Destination Slot Name

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

WebApp Name

Azure Powershell Classic Module

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Preserve Vnet Boolean

Type:System.Nullable`1[System.Boolean]
Position:3
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Resource Group Name

Create Cloud Service Azure

Type:String
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Source Slot Name

Type:String
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Azure Powershell Swap Slots Cloud Service

Swap With Preview Action

Type:System.Nullable`1[Microsoft.Azure.Commands.WebApps.Utilities.SwapWithPreviewAction]
Accepted values:ApplySlotConfig, CompleteSlotSwap, ResetSlotSwap
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

WebApp Object

Type:PSSite
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Shows what would happen if the cmdlet runs.The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Parameters: WebApp (ByValue)

Outputs

-->

In the Cloud Services area of the Azure portal, you can:

  • Update a service role or a deployment.
  • Promote a staged deployment to production.
  • Link resources to your cloud service so that you can see the resource dependencies and scale the resources together.
  • Delete a cloud service or a deployment.

For more information about how to scale your cloud service, see Configure auto-scaling for a cloud service in the portal.

Update a cloud service role or deployment

If you need to update the application code for your cloud service, use Update on the cloud service blade. You can update a single role or all roles. To update, you can upload a new service package or service configuration file.

  1. In the Azure portal, select the cloud service you want to update. This step opens the cloud service instance blade.

  2. On the blade, select Update.

  3. Update the deployment with a new service package file (.cspkg) and service configuration file (.cscfg).

  4. Optionally, update the storage account and the deployment label.

  5. If any roles have only one role instance, select the Deploy even if one or more roles contain a single instance check box to enable the upgrade to proceed.

    Azure can guarantee only 99.95 percent service availability during a cloud service update if each role has at least two role instances (virtual machines). With two role instances, one virtual machine processes client requests while the other is updated.

  6. Select the Start deployment check box to apply the update after the upload of the package has finished.

  7. Select OK to begin updating the service.

Swap deployments to promote a staged deployment to production

When you decide to deploy a new release of a cloud service, stage and test your new release in your cloud service staging environment. Use Swap to switch the URLs by which the two deployments are addressed and promote a new release to production.

Azure Powershell Swap Slots Cloud Service

You can swap deployments from the Cloud Services page or the dashboard.

  1. In the Azure portal, select the cloud service you want to update. This step opens the cloud service instance blade.

  2. On the blade, select Swap.

  3. The following confirmation prompt opens:

  4. After you verify the deployment information, select OK to swap the deployments.

    The deployment swap happens quickly because the only thing that changes is the virtual IP addresses (VIPs) for the deployments.

    To save compute costs, you can delete the staging deployment after you verify that your production deployment is working as expected.

Common questions about swapping deployments

What are the prerequisites for swapping deployments?

There are two key prerequisites for a successful deployment swap:

  • If you want to use a static IP address for your production slot, you must reserve one for your staging slot as well. Otherwise, the swap fails.

  • All instances of your roles must be running before you can perform the swap. You can check the status of your instances on the Overview blade of the Azure portal. Alternatively, you can use the Get-AzureRole command in Windows PowerShell.

Note that guest OS updates and service healing operations also can cause deployment swaps to fail. For more information, see Troubleshoot cloud service deployment problems.

Does a swap incur downtime for my application? How should I handle it?

As described in the previous section, a deployment swap is typically fast because it's just a configuration change in the Azure load balancer. In some cases, it can take 10 or more seconds and result in transient connection failures. To limit impact to your customers, consider implementing client retry logic.

Delete deployments and a cloud service

Before you can delete a cloud service, you must delete each existing deployment.

To save compute costs, you can delete the staging deployment after you verify that your production deployment is working as expected. You are billed for compute costs for deployed role instances that are stopped.

Use the following procedure to delete a deployment or your cloud service.

  1. In the Azure portal, select the cloud service you want to delete. This step opens the cloud service instance blade.

  2. On the blade, select Delete.

  3. To delete the entire cloud service, select the Cloud service and its deployments check box. Or you can choose either the Production deployment or the Staging deployment check box.

  4. Select Delete at the bottom.

  5. To delete the cloud service, select Delete cloud service. Then, at the confirmation prompt, select Yes.

Note

When a cloud service is deleted and verbose monitoring is configured, you must delete the data manually from your storage account. For information about where to find the metrics tables, see Introduction to cloud service monitoring.

Find more information about failed deployments

Azure Powershell Get Cloud Services

The Overview blade has a status bar at the top. When you select the bar, a new blade opens and displays any error information. If the deployment doesn't contain any errors, the information blade is blank.

How To Run Azure Powershell

Next steps

Azure Powershell Cloud Service Classic

  • General configuration of your cloud service.
  • Learn how to deploy a cloud service.
  • Configure a custom domain name.
  • Configure SSL certificates.