Create Azure Website Staging Slot. Requires Azure PowerShell to be installed on Tentacle machine

Octopus.Script exported 2015-03-25 by trailmax belongs to ‘Azure’ category.

Creates a staging slot for Azure Website.

Provides Azure publish url as variable:

 #{Octopus.Action[Create Staging Slot Step Name].Output.AzurePublishUrl}

And Username/Password for publishing:

#{Octopus.Action[Create Staging Slot Step Name].Output.AzureUsername}
#{Octopus.Action[Create Staging Slot Step Name].Output.AzurePassword}

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

Azure Web Site Name

AzureWebSite

Name of the web-site in Azure

Script body

Steps based on this template will execute the following PowerShell script.

# Check if Windows Azure Powershell is avaiable 
try{ 
    Import-Module Azure -ErrorAction Stop
}catch{
    throw "Windows Azure Powershell not found! Please make sure to install them from http://www.windowsazure.com/en-us/downloads/#cmd-line-tools" 
}


$stagingWebsite = Get-AzureWebsite -Name $AzureWebSite -Slot staging -ErrorAction SilentlyContinue


if($stagingWebsite -eq $null)
{
    Write-Host "Creating staging slot"
    $stagingWebsite = New-AzureWebsite -Name $AzureWebSite -Slot staging -Location $Location
}


Set-OctopusVariable -name "AzurePassword" -value $stagingWebsite.PublishingPassword
Set-OctopusVariable -name "AzureUsername" -value $stagingWebsite.PublishingUsername

$urlString = ($stagingWebsite.SiteProperties.Properties | ?{ $_.Name -eq "RepositoryURI" }).Value.ToString()
$url = [System.Uri]$urlString


Set-OctopusVariable -Name "AzurePublishUrl" -value $url.Host

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "2f763d9e-81e1-4ce2-a897-3fe2c72ab9f0",
  "Name": "Create Azure Website Staging Slot. Requires Azure PowerShell to be installed on Tentacle machine",
  "Description": "Creates a staging slot for Azure Website. \n\nProvides Azure publish url as variable:\n\n     #{Octopus.Action[Create Staging Slot Step Name].Output.AzurePublishUrl}\n\nAnd Username/Password for publishing:\n\n    #{Octopus.Action[Create Staging Slot Step Name].Output.AzureUsername}\n    #{Octopus.Action[Create Staging Slot Step Name].Output.AzurePassword}",
  "Version": 5,
  "ExportedAt": "2015-03-25T08:51:15.660+00:00",
  "ActionType": "Octopus.Script",
  "Author": "trailmax",
  "Parameters": [
    {
      "Name": "AzureWebSite",
      "Label": "Azure Web Site Name",
      "HelpText": "Name of the web-site in Azure",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.ScriptBody": "# Check if Windows Azure Powershell is avaiable \ntry{ \n    Import-Module Azure -ErrorAction Stop\n}catch{\n    throw \"Windows Azure Powershell not found! Please make sure to install them from http://www.windowsazure.com/en-us/downloads/#cmd-line-tools\" \n}\n\n\n$stagingWebsite = Get-AzureWebsite -Name $AzureWebSite -Slot staging -ErrorAction SilentlyContinue\n\n\nif($stagingWebsite -eq $null)\n{\n    Write-Host \"Creating staging slot\"\n    $stagingWebsite = New-AzureWebsite -Name $AzureWebSite -Slot staging -Location $Location\n}\n\n\nSet-OctopusVariable -name \"AzurePassword\" -value $stagingWebsite.PublishingPassword\nSet-OctopusVariable -name \"AzureUsername\" -value $stagingWebsite.PublishingUsername\n\n$urlString = ($stagingWebsite.SiteProperties.Properties | ?{ $_.Name -eq \"RepositoryURI\" }).Value.ToString()\n$url = [System.Uri]$urlString\n\n\nSet-OctopusVariable -Name \"AzurePublishUrl\" -value $url.Host",
    "Octopus.Action.Script.Syntax": "PowerShell"
  },
  "Category": "Azure",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/create-azure-website-staging-slot.json",
  "Website": "/step-templates/2f763d9e-81e1-4ce2-a897-3fe2c72ab9f0",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRF////AHjXf7vrv931QJrh7/f8EIDaIIncMJHfYKvmz+b3n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ul9RyK6ZScr+tk7oNrFj0o7HQUlj4EiEvJ6rPLKSmlMZCrksl1OnLaRkxc+/HB1naMhNtT/6yM2bDs6azCRHrM3aVPN7aW8irD/10B8njpAMcsl8okXcdKrl4sPsLmQVy/Sj90ucPRc/d/Bxxj+dXSpCayen32D+hLi16MsIV8gfCXrYp6ySsiJKRUF0XXiLpVbFU+fNv4r7mOwhFsX4ZdwpSi1DYs2jb6ebZ9788cblTzMrYhu7sf/17IFdtuviJ2ioHA6pMHkoH4CLUeMBU7iGkxuM/YgcdderF9ibRdc7O982F1HpYhjfWUe+x5a6pjop9iNLfoePvlsdZdTSMwfxSmTY20Q0eHnUNzga1edeNmmqbg18aMVR1L9vwSXHF9TfIWBxpKLs2hj3eQeBC0USvp2HHF3eIkRdhFOd6ER8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/I/4J8AAo/80BciBec4AAAAASUVORK5CYII=",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Wednesday, March 25, 2015