Here are the Azure PowerShell cmdlets required to create an Azure App Service Web App:
- Set-AzureWebsite (also have a look here at the New-AzureRmResource cmdlet)
Find the complete cmdlets and parameter values below.
Executing that cmdlet opens a challenge/response window, enter your credentials and the result is similar to that shown in Figure 1.
Figure 1, how to login into Azure using Azure PowerShell
Next, execute the Set-AzureRmContext cmdlet.
Set-AzureRmContext -SubscriptionId "25ec5bae-####-####-####-############"
Set the subscription Id to the subscription into which you want to create the Azure App Service Web App, the results is similar to that in Figure 2.
Figure 2, how to set the Azure subscription using Azure PowerShell
Now, navigate to the Azure App Service Web App, click on the Application settings and you will see the App Setting, Figure 3, which is not Sticky, in this example it is called MakeThisOneSticky.
Figure 3, an app setting which is not sticky to the slot and will be moved when a swap happens
To make that App Setting sticky, execute the following:
Set-AzureWebsite -Name "stickyslot" -SlotStickyAppSettingNames "MakeThisOneSticky"
NOTE: notice the name of the parameter is plural. This means that if you do not include ALL the names which need to be sticky then, the ones not included are unchecked and become not sticky anymore. So, as the STICKYSLOT App setting needs also to be sticky, execute this command:
Set-AzureWebsite -Name "stickyslot" -SlotStickyAppSettingNames @("MakeThisOneSticky", "STICKYSLOT")
Then you will notice that both are then sticky to the slot as expected.
The same goes for making the connection string sticky, execute the following Azure PowerShell cmdlet to make the connection string sticky.
Set-AzureWebsite -Name "stickslot" -SlotStickyConnectionStringNames "StickySlotConnectionString"
There is no output to these cmdlets, as shown in Figure 4. Nonetheless, if there is no error, then the cmdlet was successful and can be confirmed in the portal if required.
Figure 4, set an app setting or connection string to be sticky
This post first appeared on MSDN Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The MSDN Blogs., please read the originial post: here