Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem creating eventhub consumer-group (IOT-hub, 2021-03-03-preview API) #15545

Closed
ramondeklein opened this issue Sep 13, 2021 · 3 comments
Closed
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. IoT Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@ramondeklein
Copy link

The IotHubResourceClient.CreateEventHubConsumerGroup function requires a EventHubConsumerGroupBodyDescription object that is sent in the body. This structure isn't documented and has been added in 2021-03-03-preview. It seems that it should also contain the consumer-group name (as seen in this example). This seems redundant (it's already in the URL), but to be able to use the SDK I send the name of the consumer-group too.

I have issued a request to create a consumer-group that generates the following request (I have removed the subscription-id for privacy reasons and formatted the JSON data for clarity):

PUT /subscriptions/<subscription-id>/resourceGroups/acctestRG-210913193521490604/providers/Microsoft.Devices/IotHubs/acctestIoTHub-210913193521490604/eventHubEndpoints/events/ConsumerGroups/test?api-version=2021-03-03-preview HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.17 (amd64-linux) go-autorest/v14.2.1 Azure-SDK-For-Go/v57.0.0 devices/2021-03-03-preview HashiCorp Terraform/1.0.6 (+https://www.terraform.io) Terraform Plugin SDK/2.7.0 terraform-provider-azurerm/acc pid-222c6c49-1b0a-5959-a213-6608f9eb8820
Content-Length: 30
Content-Type: application/json; charset=utf-8
X-Ms-Correlation-Request-Id: 4e53d1f1-985b-1630-12b2-1d9c72fc0c57
Accept-Encoding: gzip

{
  "properties": {
    "name": "test"
  }
}

The name is sent in the body and the response is processed correctly, because the following response is received:

HTTP/2.0 200 OK
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Mon, 13 Sep 2021 17:38:03 GMT
Expires: -1
Pragma: no-cache
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: 4e53d1f1-985b-1630-12b2-1d9c72fc0c57
X-Ms-Ratelimit-Remaining-Subscription-Writes: 1198
X-Ms-Request-Id: 472d6a96-c40d-4dfa-9bd3-194cfa1bac87
X-Ms-Routing-Request-Id: WESTEUROPE:20210913T173803Z:472d6a96-c40d-4dfa-9bd3-194cfa1bac87

{
  "properties": {
    "created": "Mon, 13 Sep 2021 17:38:03 GMT",
    "properties": {
      "name": "test"
    }
  },
  "id": "/subscriptions/<subscription-id>/resourceGroups/acctestRG-210913193521490604/providers/Microsoft.Devices/IotHubs/acctestIoTHub-210913193521490604/eventHubEndpoints/events/ConsumerGroups/test",
  "name": "test",
  "type": "Microsoft.Devices/IotHubs/EventHubEndpoints/ConsumerGroups",
  "etag": null
}

There seems to be an issue with the returned properties field in the response. The entire response is unmarshalled into the EventHubConsumerGroupInfo structure:

type EventHubConsumerGroupInfo struct {
    autorest.Response `json:"-"`
    Properties map[string]*string `json:"properties"`
    ID *string `json:"id,omitempty"`
    Name *string `json:"name,omitempty"`
    Type *string `json:"type,omitempty"`
    Etag *string `json:"etag,omitempty"`
}

The structure contains the properties field, but it's marked as map[string]*string. The API returns a properties field that also embeds the input properties map, so this can't be deserialized and fails. I guess it's a buck in the API back-end, because it seems pretty useless to have properties within properties, but I did also check the .NET SDK and it defines the properties like this:

[JsonProperty(PropertyName = "properties")]
public IDictionary<string, object> Properties { get; set; }

I guess creating consumer-groups is broken with the 2021-03-03-preview API. I also am wondering why the name should also be sent in the request body.

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 13, 2021
@ramondeklein ramondeklein changed the title Problem creating eventhub constumer-group (IOT-hub, 2021-03-03-preview API) Problem creating eventhub consumer-group (IOT-hub, 2021-03-03-preview API) Sep 13, 2021
@RickWinter RickWinter added IoT Mgmt This issue is related to a management-plane library. labels Sep 13, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 13, 2021
@tadelesh
Copy link
Member

Thank you for your feedback. As for the CreateEventHubConsumerGroup unmarshall crash, we will resolve it by next SDK release which will upgrade iothub api version to 2021-03-31.

@tadelesh tadelesh added the Service Attention Workflow: This issue is responsible by Azure service team. label Sep 17, 2021
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Sep 17, 2021
@tadelesh
Copy link
Member

@ramondeklein We have released v57.4.0, you can try new api version: github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2021-03-31/devices. Have fun, thanks.

@tadelesh tadelesh assigned tadelesh and unassigned tadelesh and lirenhe Sep 23, 2021
ramondeklein added a commit to ramondeklein/terraform-provider-azurerm that referenced this issue Sep 23, 2021
@ramondeklein
Copy link
Author

Works fine.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. IoT Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants