Search code examples
powershellazureazure-blob-storageazure-powershellazure-stream-analytics

Error when creating a blob storage output for Stream Analytics using Powershell


I'm trying to create a Stream Analytics blob storage output using powershell. This is the command I'm using:

New-AzureRMStreamAnalyticsOutput -ResourceGroupName $ResourceGroupName -JobName $JobName –File soutput.json" -Force

and the output.json file looks like this:

{
  "name":  "test",
  "properties":  {
    "datasource":  {
        "type":  "Microsoft.Storage/Blob",
            "properties":  {
                "storageAccounts":  ["testStorage"],
                "container":  "testContainer",
                "pathPattern":  "",
                "accountName":  "testStorage",
                "accountKey":  "storage-key"
            }
        }
    }
}

And I'm getting this error:

New-AzureRMStreamAnalyticsOutput : HTTP Status Code: BadRequest
Error Code: BadRequest
Error Message: The JSON provided in the request body is invalid. 
Error converting value "testStorage" to type 'Microsoft.Streaming.Service.Contracts.CSMResourceProvider.BlobConnectionInfo'. 
Path 'properties.storageAccounts[0]', line 8, position 106.

What should be in the storageAccounts property?


Solution

  • What should be in the storageAccounts property?

    We need to set storageAccounts property:

     "StorageAccounts": [
                         {
                             "AccountKey": "storagekey",
                              "AccountName": "storageaccount"
                         }
                        ]
    

    Property "Serialization" need to be included in the output json file.Please have a try to use output.json file as following. It works correctly for me.

    {
       "Name": "S3PSAJobOutPut",
       "Properties": {
                        "DataSource": {
                        "Properties": {
                        "Container": "s3psaoutput",
                        "PathPattern": "",
                        "StorageAccounts": [
                         {
                             "AccountKey": "storagekey",
                              "AccountName": "storageaccount"
                         }
                                ]
                      },
                      "Type": "Microsoft.Storage/Blob"
                      },
                      "Serialization": {
                              "Properties": {
                                "Encoding": "UTF8",
                                "Format": "LineSeparated"
                              },
                              "Type": "Json"
                            }
    
                      }
    }
    

    enter image description here