0

I am trying to create a bot service using command New-AzureRmResource

i have a resourcegroup create - testRG

properties:

@{
    Location = "global"
    Properties        = @{
    MsaAppId = <<appid>>}
    ResourceName   = "test"
    ResourceType   = "Microsoft.BotService/botServices/"
    ResourceGroupName = "testRG"
    Force             = $true
}

but i keep getting the following error:

InvalidBotData : Name: Name is required.

I tried adding 'Name' field to properties but that fails with the same error

I also tried using New-AzureRmResourceGroupDeployment with same details in my template file but i get the same error:

New-AzureRmResourceGroupDeployment : 1:33:48 PM - Resource Microsoft.BotService/botServices '...' failed with message 
{
    "error": {
        "code": "InvalidBotData",
        "message": "Name: Name is required. "
    }
}

how can I directly create a bot service using powershell/any other scripting language without having to go to azure portal?

Andrei Suvorkov
  • 5,559
  • 5
  • 22
  • 48
  • Are you setting the -Properties as hashtable? It says here (https://learn.microsoft.com/en-us/powershell/module/azurerm.resources/new-azurermresource?view=azurermps-6.5.0) it expects a PSObject. – Theo Jul 21 '18 at 12:05
  • @Theo `PSObject` is the `object` of powershell. It's a generic that could take anything. – Maximilian Burszley Jul 21 '18 at 18:34
  • @TheIncorrigible1 I think the function is not expecting a property called **Name**, but it wants to find the NAMES of the properties. The OP shows Hashtable and the docs say that `New-AzureRmResource` expects a **PSObject** in its `-Properties`. I think it enumerates the names/values of the properties like with `$obj.PSObject.Properties`. A PSObject has **Name** and **Value**. A Hastable uses **Key** and **Value**. Hence perhaps the criptic error message. Wouldn't hurt to try `$psProps = New-Object PSObject -Property @{...}` and use this with `New-AzureRmResource -Properties $psProps ...` – Theo Jul 22 '18 at 08:58

1 Answers1

1

You could use azure CLI to create a bot. Enable the Azure CLI bot extension and create a new bot.

Please refer to the command below.

az bot create --resource-group "my-resource-group" --name "my-bot-name" --kind "my-resource-type" --description "description-of-my-bot"

I use the command to create a web type bot, it works fine on my side.

enter image description here

Check it in the portal.

enter image description here For more details about the properties, refer to this link.

Joy Wang
  • 39,905
  • 3
  • 30
  • 54