Azure Websites Archives - RuslanY Blog Azure App Service Features and Best Practices Fri, 31 Jan 2020 19:31:21 +0000 en-US hourly 1 https://wordpress.org/?v=6.2.16 https://ruslany.net/wp-content/uploads/2019/05/cropped-web-32x32.png Azure Websites Archives - RuslanY Blog 32 32 How to monitor Azure App Service content changes and publishing activity https://ruslany.net/2020/01/how-to-monitor-azure-app-service-content-changes-and-publishing-activity/ https://ruslany.net/2020/01/how-to-monitor-azure-app-service-content-changes-and-publishing-activity/#respond Mon, 13 Jan 2020 23:08:58 +0000 https://ruslany.net/?p=424476 There are various ways to deploy an Azure App Service content: FTP, GitHub actions, deploy from Zip and many others. With Azure Role-Based Access Control it is possible to have many different users with contributor access who can deploy new content or modify existing files. In those situations it may be important to track who … Continue reading "How to monitor Azure App Service content changes and publishing activity"

The post How to monitor Azure App Service content changes and publishing activity appeared first on RuslanY Blog.

]]>
There are various ways to deploy an Azure App Service content: FTP, GitHub actions, deploy from Zip and many others. With Azure Role-Based Access Control it is possible to have many different users with contributor access who can deploy new content or modify existing files. In those situations it may be important to track who made the content changes and when. Some companies or businesses may need this capability for various compliance requirements. This blog post explains how to enable the monitoring of app service content publishing activity and content file changes.

Azure App Service is integrated with Azure Monitor which makes many app service logs available in Azure Monitor and Azure Log Analytics. The publishing activity and file change logs are also pushed to Azure Monitor and can be exported to third party services or can be used to create rule-based alerts.

Here are the configuration steps necessary to enable publishing activity and file change logging.

Create a new Log Analytics workspace

Note that this step can be omitted if you do not plan to use Log Analytics to query the logs and instead just want to make the logs available to third party log processing services.

Make sure that the workspace is created in the same region where you app service is located.

Create new Log Analytics workspace

Configure Azure Monitor diagnostic settings

In the Azure Portal select the App Service and then select the diagnostic settings:

App Service diagnostic settings

Select +Add diagnostic setting:

Add diagnostic setting

On next page you can specify what logs you need and where you need those logs to be sent to. Select the following logs:

  • AppServiceFileAuditLogs – this will generate logs for app service content files changes;
  • AppServiceAuditLogs – this will generate logs for publishing access, for example when somebody logs on via FTP.

Then select where you need those logs to be sent to. For example you can send them to a storage account of your choice and to a Log Analytics workspace that you created in a previous step. Note that the storage account has to be in the same region as the app service.

Configure logs for Azure Monitor

Scale the App Service Plan to PremiumV2 or Premium

The file change audit logs (AppServiceFileAuditLogs) are only available for app services in Premium, PremiumV2 and Isolated App Service Plans. You will need to scale up the app service plan in order to get those logs.

The publishing audit logs (AppServiceAuditLogs) are available for all App Service Plan pricing tiers.

Enable File Change Audit for the App Service

The last step is to switch on the File Change Audit configuration setting for the web app. At the time of writing this article there is no Portal support or client libraries for this setting yet so the easiest way to do this is via Azure Resource Explorer:

Enable file change audit in Azure Resource Explorer

How to access the logs

If you enabled sending of the logs to a storage account then you should see the insights-logs-appserviceauditlogs and insights-logs-appservicefileauditlogs containers in that storage account:

Log containers in the storage account

If you enabled sending of the logs to the Log Analytics workspace then open that workspace and go to the Logs page. That will open the query window where you can write the queries against the AppServiceFileChangeAuditLogs:

Querying file changes in the past 7 days

and AppServiceAuditLogs:

Querying the publishing access in the past 7 days

The log analytics allows you to create complex queries against these logs and also use those queries to create rule-based alerts. For example you can create an alert that will send you an email whenever a files with extension .config and *.dll are modified.

How to exclude specific files or directories from audit

If an application generates many temporary files or if it constantly writes something to a log file then this may result in very noisy audit log. To prevent this from happening you can exclude certain directories from auditing by using the audit log filter file.

Create a file named _auditLog.filter at the root directory of your site content (D:\Home) and add the directory and file paths to be excluded there:

# this is an example of an audit filter file
# it can contain file and directory paths
# it can have comments
# it can have up to 50 exclude paths
# each path can be up to 256 chars long
/LogFiles
/site/locks
/site/deployments
/site/wwwroot/applogs/phperrors.log

Known issues

  • The file change audit and publishing access audit are currently in a public preview. The functionality may have some bugs and the logs schema may change
  • The file change audit is only available for app services that run on Windows App Service plans. The Linux App Service Plans are not supported at the time of writing this article.

The post How to monitor Azure App Service content changes and publishing activity appeared first on RuslanY Blog.

]]>
https://ruslany.net/2020/01/how-to-monitor-azure-app-service-content-changes-and-publishing-activity/feed/ 0
Using ARM template to swap App Service deployment slots https://ruslany.net/2019/10/using-arm-template-to-swap-app-service-deployment-slots/ https://ruslany.net/2019/10/using-arm-template-to-swap-app-service-deployment-slots/#respond Tue, 01 Oct 2019 18:43:06 +0000 https://ruslany.net/?p=424454 Azure Resource Manager (ARM) templates are used to automate deployment and configuration of Azure resources. With the templates you can define the infrastructure to be deployed via a JSON file and then use that file to repeatedly deploy new resources or update existing ones. ARM templates are widely used to release new versions of the … Continue reading "Using ARM template to swap App Service deployment slots"

The post Using ARM template to swap App Service deployment slots appeared first on RuslanY Blog.

]]>
Azure Resource Manager (ARM) templates are used to automate deployment and configuration of Azure resources. With the templates you can define the infrastructure to be deployed via a JSON file and then use that file to repeatedly deploy new resources or update existing ones. ARM templates are widely used to release new versions of the Azure web apps and function apps. During a release the new version of an app is deployed to a staging slot and then it is swapped into production. This blog post explains how to automate the App Service deployment slot swap operation with an ARM template.

Let’s assume you have a web app with production and staging deployment slots. When you release a new version of that web app you first would deploy it to the staging slot and then swap it into production slot. To define the swap operation via ARM template you’ll need to use two properties on the “Microsoft.Web/sites” and “Microsoft.Web/sites/slots” resources:

  • buildVersion – this is a string property which can be set to any arbitrary value that would represent the current version of the app deployed in the slot. For example: “v1“, “1.0.0.1“, “2019-09-20T11:53:25.2887393-07:00“.
  • targetBuildVersion – this is a string property that is used to specify what version of the app the current slot should have. If the targetBuildVersion is different from the buildVersion then this will trigger the swap operation by finding a slot that has the expected build version and then swapping the site from that slot into the current slot.

With that the process of deploying a new version of an app can be done as follows:

  1. Deploy a new version of an app into a staging slot
  2. Execute ARM template to update the buildVersion of the app in staging slot
  3. Execute ARM template to set the targetBuildVersion on the production slot

Here is an example ARM template that demonstrates how to perform steps #2 and #3:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "sites_SwapAPIDemo_name": {
            "defaultValue": "SwapAPIDemo",
            "type": "String"
        },
        "sites_buildVersion": {
            "defaultValue": "v1",
            "type": "String"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Web/sites/slots",
            "apiVersion": "2018-02-01",
            "name": "[concat(parameters('sites_SwapAPIDemo_name'), '/staging')]",
            "location": "East US",
            "kind": "app",
            "properties": {
                "buildVersion": "[parameters('sites_buildVersion')]"
            }
        },
        {
            "type": "Microsoft.Web/sites",
            "apiVersion": "2018-02-01",
            "name": "[parameters('sites_SwapAPIDemo_name')]",
            "location": "East US",
            "kind": "app",
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites/slots', parameters('sites_SwapAPIDemo_name'), 'staging')]"
            ],
            "properties": {
                "targetBuildVersion": "[parameters('sites_buildVersion')]"
            }
        }        
    ]
}

This ARM template is idempotent, meaning that it can be executed repeatedly and produce the same state of the slots. In other words if you re-run the same template with the same parameters after the swap has been performed and targetBuildVersion on production slot matches the buildVersion then it will not trigger another swap.

The post Using ARM template to swap App Service deployment slots appeared first on RuslanY Blog.

]]>
https://ruslany.net/2019/10/using-arm-template-to-swap-app-service-deployment-slots/feed/ 0
Azure App Service Deployment Slots Tips and Tricks https://ruslany.net/2019/06/azure-app-service-deployment-slots-tips-and-tricks/ https://ruslany.net/2019/06/azure-app-service-deployment-slots-tips-and-tricks/#comments Tue, 04 Jun 2019 19:21:32 +0000 https://ruslany.net/?p=424386 This post explains some of the not so well-known features and configurations settings of the Azure App Service deployment slots. These can be used to modify the swap logic as well as to improve the application availability during and after the swap. Here is what you can do with them: Swap slots only if the … Continue reading "Azure App Service Deployment Slots Tips and Tricks"

The post Azure App Service Deployment Slots Tips and Tricks appeared first on RuslanY Blog.

]]>
This post explains some of the not so well-known features and configurations settings of the Azure App Service deployment slots. These can be used to modify the swap logic as well as to improve the application availability during and after the swap. Here is what you can do with them:

Swap based on the status code

During the swap operation the site in the staging slot is warmed up by making an HTTP request to its root directory. More detailed explanation of that process is available at How to warm up Azure Web App during deployment slots swap. By default the swap will proceed as long as the site responds with any status code. However, if you prefer the swap to not proceed if the application fails to warm up then you can configure it by using these app settings:

  • WEBSITE_SWAP_WARMUP_PING_PATH: The path to make the warm up request to. Set this to a URL path that begins with a slash as the value. For example, “/warmup.php”. The default value is /.
  • WEBSITE_SWAP_WARMUP_PING_STATUSES:Expected HTTP response codes for the warm-up operation. Set this to a comma-separated list of HTTP status codes. For example: “200,202” . If the returned status code is not in the list, the swap operation will not complete. By default, all response codes are valid.

You can mark those two app setting as “Slot Settings” which would make them remain with the slot during the swap. Or you can have them as “non-sticky” settings meaning that they would move with the site as it gets swapped between slots.

Minimize random cold starts

In some cases after the swap the web app in the production slot may restart later without any action taken by the app owner. This usually happens when the underlying storage infrastructure of Azure App Service undergoes some changes. When that happens the application will restart on all VMs at the same time which may result in a cold start and a high latency of the HTTP requests. While you cannot control the underlying storage events you can minimize the effect they have on your app in the production slot. Set this app setting on every slot of the app:

  • WEBSITE_ADD_SITENAME_BINDINGS_IN_APPHOST_CONFIG: setting this to “1” will prevent web app’s worker process and app domain from recycling when the App Service’s storage infrastructure gets reconfigured.

The only side effect this setting has is that it may cause problems when used with some Windows Communication Foundation (WCF) application. If you app does not use WCF then there is no downside of using this setting.

Control SLOT-sticky configuration

Originally when deployment slots functionality was released it did not properly handle some of the common site configuration settings during swap. For example if you configured IP restrictions on the production slot but did not configure that on the staging slot and then performed the swap you would have had the production slot without any IP restrictions configuration, while the staging slot had the IP restrictions enabled. That did not make much sense so the product team has fixed that. Now the following settings always remain with the slot:

  • IP Restrictions
  • Always On
  • Protocol settings (Https Only, TLS version, client certificates)
  • Diagnostic Log settings
  • CORS

If however for any reason you need to revert to the old behavior of swapping these settings then you can add the app setting WEBSITE_OVERRIDE_PRESERVE_DEFAULT_STICKY_SLOT_SETTINGS to every slot of the app and set its value to “0” or “false”.

swap Diagnostics detector

If a swap operation did not complete successfully for any reason you can use the diagnostics detector to see what has happened during the swap operation and what caused it to fail. To get to it use the “Diagnose and solve problems” link in the portal:

How to find the Swap Diagnostics detector

From there click on “Check Swap Operations” which will open a page showing all the swaps performed on the webapp and their results. It will include possible root causes for the failures and recommendations on how to fix them.

Check Swap Operations page

The post Azure App Service Deployment Slots Tips and Tricks appeared first on RuslanY Blog.

]]>
https://ruslany.net/2019/06/azure-app-service-deployment-slots-tips-and-tricks/feed/ 30
Using Azure Activity Log to check the progress of deployment slots swap operation https://ruslany.net/2018/03/using-azure-activity-log-to-check-the-progress-of-deployment-slots-swap-operation/ https://ruslany.net/2018/03/using-azure-activity-log-to-check-the-progress-of-deployment-slots-swap-operation/#comments Thu, 08 Mar 2018 18:10:38 +0000 http://ruslany.net/?p=424244 If you use Azure Web App Deployment Slots then you may have noticed that sometimes the swap action may take a while to complete. This may happen when an application that is being swapped into production has a long warmup/initialization phase. It has to be warmed up on every VM in an App Service Plan … Continue reading "Using Azure Activity Log to check the progress of deployment slots swap operation"

The post Using Azure Activity Log to check the progress of deployment slots swap operation appeared first on RuslanY Blog.

]]>
If you use Azure Web App Deployment Slots then you may have noticed that sometimes the swap action may take a while to complete. This may happen when an application that is being swapped into production has a long warmup/initialization phase. It has to be warmed up on every VM in an App Service Plan and that sometimes takes minutes (more detailed description of what happens during the swap can be found in Most common deployment slot swap failures and how to fix them). This blog post explains how to see the progress and the result of the swap operation in the Azure Activity Log.

To see the swap operation events use the Activity log view in the Azure Portal:

Activity Log

Here is an example of how the swap events look like:

Swap events example
  1. ApplySlotConfig – this is logged when slot settings from production slot have been applied to a webapp in the staging slot
  2. StartSlotWarmup – this is logged when starting to initialize the webapp in the staging slot
  3. EndSlotWarmup – this indicates that the webapp initialization has completed
  4. SlotSwap – this is logged when the webapp from the staging slot has been swapped into production slot.

If there was a failure while swapping the slots then the events will look like below. The event description will have explanation of why the failure occurred.

Failed swap event in activity log

If you use PowerShell then you can get the swap related events by using this command:

Get-AzureRmLog -ResourceGroup slotswaptest -StartTime 2018-03-07 -Caller SlotSwapJobProcessor

This will produce an output as below:

Activity Log in PowerShell

(For more information on how to get Activity Log events via Powershell refer to View activity logs to audit actions on resources)

If you prefer to call the Azure API’s directly (or by using ARMClient tool) then you make a request like below:

ArmClient.exe GET "//providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&$filter=eventTimestamp ge '2018-03-07T00:00:00Z' and eventTimestamp le '2018-03-08T23:00:00Z' and resourceGroupName eq 'slotswaptest'"

In the response look for events that have Caller property set to “SlotSwapJobProcessor“.

The post Using Azure Activity Log to check the progress of deployment slots swap operation appeared first on RuslanY Blog.

]]>
https://ruslany.net/2018/03/using-azure-activity-log-to-check-the-progress-of-deployment-slots-swap-operation/feed/ 7
Most common deployment slot swap failures and how to fix them https://ruslany.net/2017/11/most-common-deployment-slot-swap-failures-and-how-to-fix-them/ https://ruslany.net/2017/11/most-common-deployment-slot-swap-failures-and-how-to-fix-them/#comments Thu, 02 Nov 2017 21:30:01 +0000 http://ruslany.net/?p=419544 Azure Web App Deployment Slots are used to deploy new versions of an application code into production with no interruption to the production traffic. In order to achieve this the swap process involves multiple steps that are performed to prepare the new version of the code to successfully handle the load once it is in … Continue reading "Most common deployment slot swap failures and how to fix them"

The post Most common deployment slot swap failures and how to fix them appeared first on RuslanY Blog.

]]>
Azure Web App Deployment Slots are used to deploy new versions of an application code into production with no interruption to the production traffic. In order to achieve this the swap process involves multiple steps that are performed to prepare the new version of the code to successfully handle the load once it is in production slot. Some of these steps may go wrong, especially when the new version of the code does not cooperate well. This in turn either causes the swap to fail or it results in swapping new code in production while it is still not ready to handle the production load. This post describes the most common reasons why this may happen and how to correct them.

In order to better understand the reasons for the swap failures it is first necessary to explain how the application code in the staging slot is initialized / warmed up prior to the swap to production. Failures during these steps are the most common reasons for the overall failure of the swap operation.

The swap operation is done by an internal process that runs within a scale unit where web app is hosted. Here are the steps that it performs to ensure the application is initialized prior to the swap. Note that the same sequence of actions happens during Auto-Swap and Swap with Preview.

  • Apply the production configuration settings to all web app’s instances in the staging slot. This happens when web app has appsettings or connection strings marked as “Slot settings” or if Continuous Deployment is enabled for the site or if Site Authentication is enabled. This will trigger all instances in the staging slot to restart. (For Swap with Preview this the first phase of the swap after which the swap process is paused and you can validate that the application works correctly with production settings)
  • Wait for every instance to complete its restart. If some instance failed to restart then the swap process will revert any configuration changes to the app in staging slot and will not proceed further. If that happens the first place to look into is the D:\home\LogFiles\eventlog.xml file of the application specific error log (such as php_errors.log for PHP apps) where you may find more clues what prevents application from starting.
  • If Local Cache is enabled then swap process will trigger Local Cache initialization by making an HTTP request to the root directory URL path (“/”) of the web app on every web worker. Local Cache Initialization consists of copying the site’s content files from network share to the local disk of the worker and then re-pointing the web app to use local disk for its content. This causes another restart of the web app. The swap process will wait until the Local Cache is completely initialized and restarted on every instance before proceeding further. A common reason why Local Cache Initialization may fail is when site content size exceeds the local disk quota specified for the Local Cache. If that is the case the the quota can be increased by following instructions from Local Cache Documentation.
  • If Application Initialization (AppInit) is enabled then swap process will make another HTTP request to the root URL path on every web worker. The AppInit is a module that runs within the web app request processing pipeline and it gets executed when web app starts. The only thing the swap process does with its first HTTP request to the web app is it triggers the AppInit module to do its work. After that it just waits until AppInit reports that it has completed the warmup. AppInit module uses the list of URL paths specified inside web.config file and makes internal HTTP requests to each of those. All these requests are within the web app process. It does not call any external URL’s and its requests are not going through the scale unit’s front ends. Also, neither the initial HTTP request nor AppInit internal requests follow HTTP redirects. That causes the most common problem that users run into with this module. If web app has such rewrite rules as “Enforce Domain” or “Enforce HTTPs” then none of the warmup requests will actually reach the application code. All the requests will be shortcut by the rewrite rules. In order to prevent that the rewrite rules need to be modified like below:
<rule name="Canonical Host Name" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
    <add input="{REMOTE_ADDR}" pattern="^100?\." negate="true" />
    <add input="{HTTP_HOST}" negate="true" pattern="^ruslany\.net$" />
  </conditions>
  <action type="Redirect" url="http://ruslany.net/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Redirect to HTTPS" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
    <add input="{REMOTE_ADDR}" pattern="^100?\." negate="true" />
    <add input="{HTTPS}" pattern="^OFF$" />
  </conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>

The {WARMUP_REQUEST} is a server variable that is set by AppInit module for each of its internal requests. That is a reliable way to distinguish whether the request is external or is made by AppInit module. The {REMOTE_ADDR} is a server variable that contains the IP address of HTTP client. The IP address ranges starting with “10.” or “100.” are internal to the scale unit and no outside HTTP client can use them.

  • If AppInit is not enabled then swap process just makes an HTTP request to the root path of the webapp on each web worker and as long as it receives some HTTP response it considers the warmup complete. Again the rewrite rules in the web app can cause the site to return HTTP redirect response and the actual application code will not be executed at all. Since the AppInit is not involved here the only way to prevent the rewrite rules is to use the {REMOTE_ADDR} server variable in the rule’s conditions as shown below.
<conditions>
  <add input="{REMOTE_ADDR}" pattern="^100?\." negate="true" />
</conditions>
  • After all the above steps are completed successfully the actual swap is performed by switching the routing rules on the scale unit’s front ends. More details on what happens during the swap can be found in other blog post “How to warm up Azure Web App during deployment slots swap”

Some other common problems that cause the swap to fail:

  • An HTTP request to the root URL path times out. The swap process waits for 90 seconds for the request to return. In case of timeout the request will be retried for up to 5 times. If after that the request still times out then the swap operation will be aborted. If that happens then check the eventlog.xml or application specific error log to see if there are any indications of what causes the timeout.
  • An HTTP request to the root URL path is aborted. This may happen if web app has a rewrite rule to abort some requests. If that is the case then the rule can be modified by adding the {REMOTE_ADDR} check as shown in previous examples.
  • Web App has IP restriction rules that prevent the swap process from connecting to it. In that case you’ll need to allow the internal IP address range used by the swap process:

The post Most common deployment slot swap failures and how to fix them appeared first on RuslanY Blog.

]]>
https://ruslany.net/2017/11/most-common-deployment-slot-swap-failures-and-how-to-fix-them/feed/ 17
Using Powershell to manage Azure Web App Deployment Slots https://ruslany.net/2016/10/using-powershell-to-manage-azure-web-app-deployment-slots/ https://ruslany.net/2016/10/using-powershell-to-manage-azure-web-app-deployment-slots/#comments Fri, 28 Oct 2016 00:41:20 +0000 http://ruslany.net/?p=402841 This blog post has been updated from its original version in order to use the correct names of the PowerShell cmdlets. This blog post explains how to perform common management tasks for Azure Web App deployment slots by using Powershell cmdlets. To learn more about deployment slots refer to the Azure documentation and my previous … Continue reading "Using Powershell to manage Azure Web App Deployment Slots"

The post Using Powershell to manage Azure Web App Deployment Slots appeared first on RuslanY Blog.

]]>

This blog post has been updated from its original version in order to use the correct names of the PowerShell cmdlets.

This blog post explains how to perform common management tasks for Azure Web App deployment slots by using Powershell cmdlets. To learn more about deployment slots refer to the Azure documentation and my previous blog posts: Azure Web App Deployment Slot Swap with Preview and How to warm up Azure Web App during deployment slots swap.

Create a new deployment slot for an existing web app

$rg = "SomeResourceGroupName"
$site = "SomeSiteName"
New-AzWebAppSlot -ResourceGroupName $rg -name $site -slot staging

List deployment slots for a web app

Get-AzWebAppSlot -ResourceGroupName $rg -name $site

Delete a deployment slot

Remove-AzWebAppSlot -ResourceGroupName $rg -name $site -Slot staging

Specify slot app settings and connection strings

Set-AzWebAppSlotConfigName -ResourceGroupName $rg -name $site -AppSettingNames "SlotName","Environment" -ConnectionStringNames "PrimaryDB","SecondaryDB"

This cmdlet specifies the names of app settings and connection strings that will be treated as slot settings, meaning that they will remain with the slot during swap.

Set the app setting values on web app and on its slots

Set-AzWebApp -ResourceGroupName $rg -Name $site -AppSettings @{"SlotName" = "Production"; "Environment" = "Production"}
Set-AzWebAppSlot -ResourceGroupName $rg -Name $site -Slot staging -AppSettings @{"SlotName" = "Staging"; "Environment" = "Staging"}

Perform a regular slot swap

Switch-AzWebAppSlot -ResourceGroupName $rg -Name $site -SourceSlotName staging -DestinationSlotName production

Perform swap with preview

First check that the staging slot’s app setting have staging values:

$stagingSite = Get-AzWebAppSlot -ResourceGroupName $rg -Name $site -Slot staging
$stagingSite.SiteConfig.AppSettings

Name Value
---- -----
SlotName Staging
Environment Staging

Next perform the first step of the swap, which is to apply target slot’s setting values to the current staging slot:

Switch-AzWebAppSlot -ResourceGroupName $rg -Name $site -SourceSlotName staging -DestinationSlotName production -SwapWithPreviewAction ApplySlotConfig

Now confirm that the app setting values have changed:

$stagingSite = Get-AzWebAppSlot -ResourceGroupName $rg -Name $site -Slot staging
$stagingSite.SiteConfig.AppSettings

Name Value
---- -----
SlotName Production
Environment Production

At this point you would want to verify that the web app in the staging slot works as expected. You can make multiple requests to it to warm it up and fill up its caches, etc.

Once you are sure the app works as expected call this cmdlet to finish the swap:

Switch-AzWebAppSlot -ResourceGroupName $rg -Name $site -SourceSlotName staging -DestinationSlotName production -SwapWithPreviewAction CompleteSlotSwap

If for any reason you do not want to proceed with the swap you can reset the configuration on the staging slot back to its original state:

Switch-AzWebAppSlot -ResourceGroupName $rg -Name $site -SourceSlotName staging -DestinationSlotName production -SwapWithPreviewAction ResetSlotSwap

The post Using Powershell to manage Azure Web App Deployment Slots appeared first on RuslanY Blog.

]]>
https://ruslany.net/2016/10/using-powershell-to-manage-azure-web-app-deployment-slots/feed/ 6