I try to perform a swap between 2 Azure slots (Staging and Production) on a QA environment. For that I use PowerShell and use Switch-AzureWebsiteSlot cmdlet.
Below what I execute:
*`
Switch-AzureWebsiteSlot -Name "http://qa-2.cloudapp.net/" -Slot1
"Production" -Slot2 "Staging" -Force -Verbose -Debug
`*
But I got the following error:
Switch-AzureWebsiteSlot : The website must have at least two slots to
apply swap At
C:\PrivateAgents\agent2_work\r6\a\MyCompany-CI-Template\drop#1129\mycompany-swapslots-azure.ps1:222
char:2
+ Switch-AzureWebsiteSlot -Name "http://qa-2.cloudapp.net/" -Slot1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Switch-AzureWebsiteSlot], PSInvalidOperationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Websites.SwitchAzureWebsiteSlotCommand
DEBUG: AzureQoSEvent: CommandName - Switch-AzureWebsiteSlot; IsSuccess
- False; Duration - 00:01:02.5624486; Exception - System.Management.Automation.PSInvalidOperationException: The website
must have at least two slots to apply swap at
Microsoft.WindowsAzure.Commands.Websites.SwitchAzureWebsiteSlotCommand.ExecuteCmdlet()
at
Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
I use Debug mode to have more details but I don't understand what does it mean. I am a newbie in Azure and Powershell as well.
I made sure the right AzureSubscription is set as current one before to execute my cmdlet.
Anyone got the same issue as me before?
I have a doubt about the "-Name" value I used. I use site URL I found on the Azure portal. I don't know if it is correct.
To get the name of your websites in the subscription use the below PowerShell cmdlet:
Get-AzureWebsite
Note: The website should be something like this "constosoweb" and azure website looks like contosoweb.cloudapp.net.
For more details, you may refer "Swap Slots in Azure Web Site when there are 2 or more staging slots using Azure PowerShell".
I have a doubt about the "-Name" value I used. I use site URL I found
on the Azure portal. I don't know if it is correct.
-Name is the name of the website, we can use ARM powershell to get it:
Get-AzureRmWebApp -ResourceGroupName <resourcegroupname> -Name <webappname>
Like this:
Switch-AzureWebsiteSlot : The website must have at least two slots
According to this error message, we should add at least two slots to that website:
Then we can run Switch-AzureWebsiteSlot -Name jasonapp3 -Slot1 jasonapp32 -Slot2 jasonapp4, here is the result:
Hi Pradeep and Jason,
Thanks a lot for your help.
Thanks to your advices I figured out where was my issue. In fact we use Azure Cloud Service and not WebSite. That's why my cmdet failed.
I looked for cmdlet suit to Cloud Service and I found Move-AzureDeployment that works perfectly for me.
Thanks
Related
I'm getting an error while running the Azure cmdlet in Powershell. How do I resolve this?
I'm trying to get details of folders and files present in Azure datalake through powershell. I'm able to access the data lake through portal and access all files.
Using Azure cmdlet I've tested the connection using "Test-AzDataLakeStoreAccount -Name $Server" and it works fine too. However, when I execute the below command, it throws null pointer exception. How to resolve that?
**Get-AzDataLakeStoreChildItem -Account "****.azuredatalakestore.net" -Path "/" **
Get-AzDataLakeStoreChildItem : Object reference not set to an instance of an object.
At line:1 char:1
+ Get-AzDataLakeStoreChildItem -Account "entadls8cc9b872.azuredatalakes ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzDataLakeStoreChildItem], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.DataLakeStore.GetAzureDataLakeStoreChildItem
I can reproduce your issue in both windows powershell and azure cloud shell. It looks like a bug about the powershell module Az.DataLakeStore.
I tried Get-AzDataLakeStoreChildItem -AccountName "AccountName" -Path "/test/" which is the same as the sample in the doc, also got the same error. I also tried the Get-AzDataLakeStoreItem -AccountName "AccountName" -Path "/test/123.txt" and Test-AzDataLakeStoreItem -AccountName "AccountName" -Path "/test/123.txt", both got an error like below.
I find a github issue related to this error: https://github.com/Azure/azure-powershell/issues/8352. I think the format of the commands I have tried should be correct. The comment in this issue said 'To use datalake az module you have to use it in netcore powershell (not windows powershell)', but as I know, the Az module is cross-platform, it is not a reason, according to the doc. Another comment said the 'we have fixed this issue. Apologize for the inconvenience. It will be released as part of next release.'
I am trying to use Switch-AzureWebsiteSlot as it follows:
Switch-AzureWebsiteSlot -Name 'sitename' -slot1 'Staging' -slot2 'Production' -f
orce -verbose
However even though my website has 2 slots, Staging and the default Production I still receive the following error from Power Shell.
Switch-AzureWebsiteSlot : The website must have at least two slots to apply swap
At line:1 char:1
+ Switch-AzureWebsiteSlot -Name 'sitename' -slot1 'St ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Switch-AzureWebsiteSlot], PSInvalidOperationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Websites.SwitchAzureWebsiteSlotCommand
Do you have any ideas why? Did you also encounter this during your code journeys?
Switch-AzureWebsiteSlot is for ASM websites. In your case, I think you have created an ARM website, hence Switch-AzureWebsiteSlot is not suitable here.
To swap slot for ARM websites, you need to use below script:
$ParametersObject = #{targetSlot = "[slot name – e.g. “production”]"}
Invoke-AzureRmResourceAction -ResourceGroupName [resource group name]-ResourceType Microsoft.Web/sites/slots -ResourceName [web app name]/[slot name] -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-07-01
You can check this article for details.
Update:
Switch-AzureWebsiteSlot also works for ARM web app. My problem is that I have two subscriptions, I didn't select the correct subscription when testing the command previously. Thanks to Flemin!
Before:
Now with the right subscription:
This command works even if you have created app in ARM.
Switch-AzureWebsiteSlot -Name 'siteName' -slot1 'StagingDeploymentName' -slot2 'Production' -force -verbose
Please check the names that you have given and if the slots are up and running.
I tested this by stopping one of the deployment slots and go the same error as you got. So, I'm sure now that in your case either one slot is not in running state.
For an ARM web app, Switch-AzureWebsiteSlot does not work for me at all. Get the following error message:
Switch-AzureWebsiteSlot : No default subscription has been designated.
Use Select-AzureSubscription -Default to set the
default subscription.
From what I understand, Select-AzureSubscription is an ASM command so it's not applicable. (Instead, for ARM I need to use Select-AzureRmSubscription.)
The command Swap-AzureRmWebAppSlot is what worked for me:
Swap-AzureRmWebAppSlot -Name "sitename" -SourceSlotName "Staging" -DestinationSlotName "Production" -ResourceGroupName "<Your Resource Group Name"
Short story: I get the following error when trying to create a namespace on Azure Service Bus using Azure Powershell (Run as Administrator):
PS C:> New-AzureSBNamespace -Name mynewnamespace2 -Location "East US"
-CreateACSNamespace $true -Namespac New-AzureSBNamespace : Object reference not set to an instance of an object. At line:1 char:1
+ New-AzureSBNamespace -Name mynewnamespace2 -Location "East US" -CreateACSNamespace $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureSBNamespace], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceBus.NewAzureSBNamespaceCommand
Long story: I created a first namespace in Azure Service Bus to use Relay in buffered mode (namespace=mynewnamespace). It works great except when you want to transfer a larger set of data. For this there is the streamed mode and I found this handy example (https://code.msdn.microsoft.com/How-to-send-a-large-c36ab70e), changed appropriate settings for namespace and credentials and ran the server part from the project and I get the error
{"The remote name could not be resolved:
'mynewnamespace-sb.accesscontrol.windows.net'"}
because, of course, this ACS namespace does not exist. So I found out that I need to create the namespace the old fashioned way using PS, installed Azure CLI and run the commands below with the following result:
For a list of all Azure cmdlets type 'get-help azure'.
For a list of Windows Azure Pack cmdlets type 'Get-Command wapack'.
PS C:> azure login
info: Executing command login
|info: To sign in, use a web
browser to open the page https://aka.ms/devicelogin. Enter the code EE226448L to
authenticate. If you're signing in as an Azure AD application, use the
--username and --password parameters.
/info: Added subscription Visual Studio Enterprise with MSDN info: Setting subscription
"Visual Studio Enterprise with MSDN" as default
info: login command OK
PS C:> New-AzureSBNamespace -Name mynewnamespace2 -Location "East US" -CreateACSNamespace $true -NamespaceType Messaging
WARNING: Microsoft Azure PowerShell collects data about how users use
PowerShell cmdlets and some pro encounter. Microsoft uses this
information to improve our PowerShell cmdlets. Participation is volu
choose to participate your device automatically sends information to
Microsoft about how you use Azure Powershell.
If you choose to participate, you can stop at any time by using Azure
PowerShell as follows:
1. Use the Disable-AzureDataCollection cmdlet to turn the feature Off. The cmdlet can be found in the AzureResourceManager module To disable
data collection: PS > Disable-AzureDataCollection
If you choose to not participate, you can enable at any time by using
Azure PowerShell as follows:
1. Use the Enable-AzureDataCollection cmdlet to turn the feature On. The cmdlet can be found in the AzureResourceManager module To enable
data collection: PS > Enable-AzureDataCollection
Select Y to enable data collection [Y/N]: WARNING: You choose not to
participate in Microsoft Azure PowerShell data collection. WARNING:
The setting profile has been saved to the following path
'C:\Users\PDube\AppData\Roaming\Windows Azure Powershell\AzureDataCollectionProfile.json'.
New-AzureSBNamespace :
Object reference not set to an instance of an object. At line:1 char:1
+ New-AzureSBNamespace -Name mynewnamespace2 -Location "East US" -CreateACSNamespace $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureSBNamespace], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceBus.NewAzureSBNamespaceCommand
I tried to create the new namespace using Azure CLI on 2 different computers, thinking the first install was corrupted, but I get the exact same error.
How can I fix this error?
I have app service in my environment named "Standard" . Currently the app service is configured in standard tier small 1 instance.
Using powershell I am trying to scale the app service which will in turn scale the web apps inside this app service.
I want to change size to Medium and instances to 2.
Here is my snippet.
Login-AzureRmAccount
Set-AzureRMAppServicePlan -Name Standard -ResourceGroupName
MyWebAppRG - NumberofWorkers 2 -WorkerSize Medium
When I run this command I am getting following error
Set-AzureRMAppServicePlan : Could not load file or assembly 'Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=0.11.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
At line:11 char:1
+ Set-AzureRMAppServicePlan -Name Standard -ResourceGroupName MyWebAppRG -Numbero ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-AzureRMAppServicePlan], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Azure.Commands.WebApps.Cmdlets.AppServicePlans.SetAzureAppSe
rvicePlanCmdlet
I am not sure, what's wrong here? and what exactly this error means.
For the information, I am able to run other powershell commands just fine,example set-AzureRMResource and others. so isn't an environment issue.
Any help appreciated..
Thanks
What version of the Azure Powershell are you using? This was a known issue in Azure Powershell 1.0.0. If you are using that version, use the version below instead. Do post back if you still see issues.
https://github.com/Azure/azure-powershell/releases/tag/v1.0.1-November2015
I'm trying to manage some of my Azure Services via Powershell, using http://windowsazurewebsitescheatsheet.info/#powershell as a starting point. I was able to download and import my subscription settings just fine (Import-AzurePublishSettingsFile and Select-AzureSubscription)
After choosing my subscription, I'm attempting to run the Get-AzureWebsite command to view all of my websites, and continue onward from there. When I run that command, however, I get the following:
Import-AzurePublishSettingsFile "C:\AzureCredentials.publishsettings"
Select-AzureSubscription "My Azure Subscription"
Get-AzureWebsite
Get-AzureWebsite : String was not recognized as a valid Boolean.
At line:1 char:1
+ Get-AzureWebsite
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureWebsite], FormatException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Websites.GetAzureWebsiteCommand
Anyone have similar issues? I get this error if I run the command as stated above, or if I specify the name of my website. TIA for any help!
This might be related to a known issue enumerating a sites with SSL bindings
There was new release of Windows Azure Powershell released on 02/12. Please try with the new version.
Please run the command again with -Debug turned on, this will display request and response messages and make it easier to pinpoint the issue.