PowerShell Archives - RuslanY Blog Azure App Service Features and Best Practices Tue, 04 Jun 2019 23:32:12 +0000 en-US hourly 1 https://wordpress.org/?v=6.2.16 https://ruslany.net/wp-content/uploads/2019/05/cropped-web-32x32.png PowerShell Archives - RuslanY Blog 32 32 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
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
Setup IIS on Server Core – Windows Server 2008 R2 https://ruslany.net/2009/02/setup-iis-on-server-core-windows-server-2008-r2/ https://ruslany.net/2009/02/setup-iis-on-server-core-windows-server-2008-r2/#comments Fri, 27 Feb 2009 01:20:24 +0000 http://ruslany.net/?p=260 This post has been updated from its original version to correct the installation instructions, which have changed since the time the post was written in Feb 2009. With the addition of .NET Framework to Server Core in Windows Server 2008 R2 the Server Core installation option became even more appealing for those who want to use … Continue reading "Setup IIS on Server Core – Windows Server 2008 R2"

The post Setup IIS on Server Core – Windows Server 2008 R2 appeared first on RuslanY Blog.

]]>

This post has been updated from its original version to correct the installation instructions, which have changed since the time the post was written in Feb 2009.

With the addition of .NET Framework to Server Core in Windows Server 2008 R2 the Server Core installation option became even more appealing for those who want to use a very low footprint server for hosting their applications. Availability of .NET framework provides the following great benefits:

  1. ASP.NET support – you can now use Server Core to host your ASP.NET applications.
  2. IIS Remote Management – Server Core does not provide any user interface other than command line. But if you prefer to use IIS Manager UI to administer IIS, you can now use IIS Remote Manager to connect to IIS on Server Core and perform all the management tasks from within familiar UI of IIS Manager.
  3. PowerShell – Windows Server 2008 R2 includes IIS PowerShell snapin, which is also available on Server Core.

This post describes how to setup and configure IIS on Server Core in Windows Server 2008 R2. Specifically the following tasks are described:

  • Using oclist and ocsetup commands
  • Basic Installation of IIS
  • Installing ASP.NET
  • Installing PowerShell and IIS snap-in
  • Enabling IIS Remote Management

Using oclist and ocsetup commands

oclist command can be used to list the available and installed roles and services on the server. The output of the command looks similar to below:

oclist command output

It is important to understand how oclist renders component dependencies. For example, in the above screenshot the oclist output shows that IIS-FTPExtensibility is dependent on IIS-FTPSvc, so in order to install IIS-FTPExtensibility it is first necessary to install IIS-FTPSvc.

ocsetup command can be used to install and uninstall individual roles and services.

Basic Installation of IIS

To perform basic and default installation of IIS on Server Core run the following command:

start /w ocsetup IIS-WebServerRole

After the command has run you can run oclist | more and check which IIS components have been installed.

Installing .NET Framework

If you plan to use ASP.NET or IIS Remote Management then it is necessary to install .NET Framework first. To install it use the following commands:

start /w ocsetup NetFx2-ServerCore
start /w ocsetup NetFx2-ServerCore-WOW64

Installing ASP.NET

To install ASP.NET on Server Core run the following commands in exact same order as listed below:

start /w ocsetup WAS-NetFxEnvironment
start /w ocsetup IIS-ISAPIExtensions
start /w ocsetup IIS-ISAPIFilter
start /w ocsetup IIS-NetFxExtensibility
start /w ocsetup IIS-ASPNET

Installing PowerShell and IIS snap-in

First, install the PowerShell by running the command as below:

start /w ocsetup MicrosoftWindowsPowerShell

Next, launch the PowerShell by running this command:

\windows\system32\WindowsPowerShell\v1.0\powershell.exe

After running this command you should see a PowerShell prompt.

In order to enable the IIS snapin it is necessary to change the script execution policy by running this command:

Set-ExecutionPolicy RemoteSigned

Restart PowerShell for the policy changes to take effect. After re-entering the PowerShell import the IIS snapin:

import-module WebAdministration

After that you can get the list of available IIS cmdlets by typing

get-command –module WebAdministration

Refer to the article Managing IIS with IIS 7.0 PowerShell Snap-in for more information.

Enabling IIS Remote Management

In order to install IIS remote management service it is necessary to install .NET Framework first. Refer to the Installing .NET Framework section above for more details.

Install the IIS management service by executing this command:

start /w ocsetup IIS-ManagementService

Then enable remote management by running this command:

reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WebManagement\Server ^
/v EnableRemoteManagement /t REG_DWORD /d 1

And finally start the management service:

net start wmsvc

Now you can connect to the IIS on the Server Core from a remote machine by using IIS Remote Manager.

Acknowledgement: thanks to Saad Ladki and Thomas Deml from IIS team for explaining to me all these steps.

The post Setup IIS on Server Core – Windows Server 2008 R2 appeared first on RuslanY Blog.

]]>
https://ruslany.net/2009/02/setup-iis-on-server-core-windows-server-2008-r2/feed/ 4