> ## Content Index
> Fetch the complete content index at: https://codeisahighway.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Use CNAME to reach the staging slot in #Azure cloud services with a well known url
- URL: https://codeisahighway.com/use-cname-to-reach-the-staging-slot-in-azure-cloud-services-with-a-well-known-url/
- Published: 2015-04-13T17:50:40.000Z
- Updated: 2026-08-10T07:12:21.000Z
- Author: Stephane Lapointe
- Tags: PowerShell, DevOps, Microsoft Azure, Cloud Services, DNS, #Import 2023-07-11 16:44, #Import 2026-09-04 10:31, #Import 2026-09-04 13:56

If you already used the VIP swap functionality in a cloud service, you quickly noticed that for the production slot you have a deterministic url in the format *{cloudservicename}.cloudapp.net*. For the staging slot, that is something totally different.

## The problem: random generated name

You end up with a *{auto-generated-guid}.cloudapp.net* which makes it hard to give something usable to dev or testers since it will change again and again when you recreate a deployment in the staging slot. Azure will not help you there, they don't offer a way to have a deterministic DNS entry for the staging slot at the time of writing this article.

## A solution: Use a CNAME dns entry

To avoid that problem, you can use a CNAME entry that point to *{auto-generated-guid}.cloudapp.net*. That way you can give your users a well known url that will never change. You will need to update your CNAME entry when you perform a new deployment to your staging slot though but this can be automated.

```
param(
    [Parameter(Position=0,Mandatory=$true)]
    [string]
    $SubscriptionName,
    [Parameter(Position=1,Mandatory=$true)]
    [string]
    $ServiceName
)
$ErrorActionPreference = 'Stop'

Select-AzureSubscription -SubscriptionName $SubscriptionName
$service = Get-AzureService -ServiceName $ServiceName
$deployment = $service | Get-AzureDeployment -Slot Staging

'Staging Url is: {0}' -f $deployment.Url

```

From that sample script you have access to the staging url via *$deployment.Url*, you can then use that value to update you DNS server.

Get more information on deployments and how to manage cloud services

- [How to Manage Cloud Services](http://azure.microsoft.com/en-us/documentation/articles/cloud-services-how-to-manage/?ref=codeisahighway.com)
- [Manage Deployments in Azure](https://msdn.microsoft.com/library/azure/gg433027.aspx?ref=codeisahighway.com)