JTIM
JTIM

Reputation: 2771

Moving Notification Hub to another subsription using Azure Powershell

I have a mobileservice on my BizSpark account, and a Notification Hub on my Ultimate subscription. I wanted to add the Notification Hub to the MobileService existing on BizSpark, I got an error and asked to try again, and it disappeared:

enter image description here

I tried with several new Hub as can be seen on the picture but none of them worked, gave me errors that I did not have with my old notification hub.

I then wanted to transfer the hub to the same subscription where I followed Msdn, and used the following commands in Powershell:

PS C:\Users\johann> Import-Module Azure

PS C:\Users\johann> Login-AzureRmAccount

Environment           : AzureCloud
Account               : [email protected]
TenantId              : xxxxxx
SubscriptionId        : xxxxx
CurrentStorageAccount :

PS C:\Users\johann> Get-AzureRmSubscription

SubscriptionName : Windows Azure MSDN - Visual Studio Ultimate
SubscriptionId   : xxxULTIMATExxxx
TenantId         : 
State            : 

SubscriptionName : BizSpark
SubscriptionId   : xxxBIZSPARKxxxx
TenantId         : 
State            : 

PS C:\Users\johann> $res = Find-AzureRmResource -ResourceName 'MyNotificationHubsName'

PS C:\Users\johann> Move-AzureRmResource -DestinationResourceGroupName 'DestRG' -ResourceId $res.ResourceId -DestinationSubscriptionId 'xxxBIZSPARKxxxx'

This gives me the following error:

Move-AzureRmResource : Cannot validate argument on parameter 'ResourceId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At line:1 char:73 + ... inationResourceGroupName 'DestRG' -ResourceId $res.ResourceId -Destin ... + ~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Move-AzureRmResource], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.MoveAzureResourceCommand

Can anybody help me solve this issue?

Ensure That the account you login with is the source subscription. Verify by comparing the SubscriptionID after login with the results from Get-AzureRmSubscription.

Upvotes: 1

Views: 549

Answers (1)

Lily_user4045
Lily_user4045

Reputation: 793

Try the following cmd:

Get-AzureRMResource -ResourceName **** -ResourceGroupName **** | 
        Move-AzureRMResource -DestinationResourceGroupName *** -DestinationSubscriptionId **** -Force

Upvotes: 2

Related Questions