MartynJones87
MartynJones87

Reputation: 457

Azure Web App Powershell Resource Manager Mode - Connection String Slot Setting

I'm adding Connection Strings to my Azure Web App using the AzureResourceManager mode in Powershell.

Using the Azure Resource Explorer I've found the correct Powershell to add a connection string to my web app

$PropertiesObject = @{
    #Property = value;
    MembershipConnection = @{
        Value = "Server=tcp:members.database.windows.net,1433;Database=Membership;User ID=User@members;Password=passwordgoeshere;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
        Type = "2";
    }
}

New-AzureResource -PropertyObject $PropertiesObject -ResourceGroupName $resGroup -ResourceType Microsoft.Web/sites/config -ResourceName "$siteName/connectionstrings" -OutputObjectFormat New -ApiVersion "2015-08-01" -Force

However, I can't find a way of marking the Connection String as a Slot Setting, so that it doesn't move when switching between my Staging and Production deployment slots.

In the Portal, it's a simple checkbox alongside the connection string.

Thanks very much for any help!

Upvotes: 1

Views: 413

Answers (1)

Shaun Luttin
Shaun Luttin

Reputation: 141434

You might already know that you can do this in the Azure Service Management Mode like this:

> Switch-AzureMode -Name AzureServiceManagement
> Set-AzureWebsite -Name myapp -SlotStickyConnectionStringNames @("my_db")

I appreciate, though, that your question is about using the Azure Resource Manager.

Upvotes: 1

Related Questions