Seems that you can only create a SQL Server through the Powershell on Azure using AzureServiceManagement mode. This creates a new server for me into a default resource group named "Default-SQL-WestUS". But how can I place this into an existing Resource Group so I can manage it alongside other relevant resources?
When I have attempted using AzureResourceManagement the Cmndlet chokes on the -Name parameter:
New-AzureResource -Name "testName" -Location "West US" -ResourceGroupName "TestGroupName" -ResourceType Microsoft.Sql/servers -ApiVersion "2014-04-01"
When I run the above I get:
'' is an invalid name because it contains a NULL character or an invalid unicode character.
I've also removed the -Name parameter (thinking Azure SHOULD create this name for me as it does with ServiceManager):
New-AzureResource -Location "West US" -ResourceGroupName "TestGroupName" -ResourceType Microsoft.Sql/servers -ApiVersion "2014-04-01"
But this just prompts me for a name, and I get the same error. I've tried using a null value for name as well and get the following:
Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
Is there a better way to create a new SQL Server within a ResourceGroup in Azure?
Thanks in advance!
-- UPDATED: --
Looks like you have to? use AzureServiceManagement Mode to create a SqlServer. You cannot link a SqlServer to a Resource group (is this coming in the future?).
BUT you SHOULD be able to add a Sql Database to ResourceManager. So I switched to ServiceManagement mode, created a SqlServer, switched back to ResourceManagement mode, created a resource group and I've updated my database creation script to link to both the server and the resource group as follows:
New-AzureResource –Name "TestDBName" –ResourceType Microsoft.Sql/servers/databases –ResourceGroup "TestGroupName" –Location "West US" -ApiVersion "2014-04-01" –ParentResource servers/[servername]
Which I have seen as the correct way to do this in many examples online, but for some reason I now just get a general error that give me no indication of what went wrong
New-AzureResource : : An error occurred while processing this request.
I want to be able to create a SqlServer on Azure into an existing ResourceGroup and then add databases to the server via PowerShell. I'll be continuing to try different variations on my scripts to get this to work, but I feel as if I have hit a wall. Many thanks (and points) to anyone who can help!