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

EventHub created through sendRequest can not be deleted through sendRequest #469

Open
1 task done
smilinazzo opened this issue May 26, 2022 · 2 comments
Open
1 task done

Comments

@smilinazzo
Copy link

smilinazzo commented May 26, 2022

Package Version: 2.6.1

  • nodejs
    • nodejs version: 14.18.3
    • os name/version: macOS Monterey 12.4

Describe the bug
Looking for a bit of guidance.

I am creating and using an Event Hub as follows:

const tokenCredentials = (await AzAuth.loginWithUsernamePasswordWithAuthResponse(username, password)).credentials;
const client = new msREST.ServiceClient(tokenCredentials);

async createEventHub() {
  const req: AzREST.RequestPrepareOptions = {
    url: 'https://management.azure.com/subscriptions/[REDACTED]/resourceGroups/myGroup/providers/Microsoft.EventHub/namespaces/myNamespace/eventhubs/myEventHub?api-version=2017-04-01',
    method: 'PUT',
    body: {
      messageRetentionInDays: 1;
      partitionIds: [];
      partitionCount: 1;
      captureDescription: null;
    }
  };
  return await client.sendRequest(req);
}

async deleteEventHub() {
  const req: AzREST.RequestPrepareOptions = {
    url: 'https://management.azure.com/subscriptions/[REDACTED]/resourceGroups/myGroup/providers/Microsoft.EventHub/namespaces/myNamespace/eventhubs/myEventHub?api-version=2017-04-01',
    method: 'DELETE',
  };
  return await client.sendRequest(req);
}

await createEventHub();
// Create a Producer, send some events
await deleteEventHub();

I'm finding I can create the EventHub and use the Producer but when I attempt to delete the EventHub, the request response is 200 but the event hub is not deleted. Whats odd is that the Message Retention value will change from 1 to 7. I then have to delete it through the Portal.

If I create an EventHub through the portal UI, the delete through REST works on that EventHub.

Any ideas as to why this is?

As a note, with CURL, this works:

curl -X PUT -H 'Authorization: Bearer <token>' -H "content-type: application/json" 'https://management.azure.com/subscriptions/[REDACTED]/resourceGroups/myGroup/providers/Microsoft.EventHub/namespaces/myNamespace/eventhubs/testhub?api-version=2017-04-01' -v -d '{"properties": { "messageRetentionInDays": 1, "partitionIds": [], "partitionCount": 1, "captureDescription": null }}'

curl -X DELETE -H 'Authorization: Bearer <token>' -H "content-type: application/json" 'https://management.azure.com/subscriptions/[REDACTED]/resourceGroups/myGroup/providers/Microsoft.EventHub/namespaces/myNamespace/eventhubs/testhub?api-version=2017-04-01'

Expected behavior
Expect the EventHub to be deleted from the ResourceGroup.

Screenshots
N/A

@jeremymeng
Copy link
Member

@qiaozha any ideas?

@smilinazzo
Copy link
Author

This also seems to work from my Win11 system:

PUT:

>> Request: {
  "url": "https://management.azure.com/subscriptions/[REDACTED]/resourceGroups/MyGroup/providers/Microsoft.EventHub/namespaces/MyNamespace/eventhubs/testhub?api-version=2021-11-01",
  "method": "PUT",
  "headers": {
    "_headersMap": {
      "accept-language": {
        "name": "accept-language",
        "value": "en-US"
      },
      "x-ms-client-request-id": {
        "name": "x-ms-client-request-id",
        "value": "3bb6f99b-2cd2-43c6-b00b-80c5093ca5c6"
      },
      "content-type": {
        "name": "content-type",
        "value": "application/json; charset=utf-8"
      },
      "authorization": {
        "name": "authorization",
        "value": "Bearer <token>"
      },
      "user-agent": {
        "name": "user-agent",
        "value": "ms-rest-js/2.6.1 Node/v14.18.1 OS/(x64-Linux-4.4.0-22000-Microsoft)"
      },
      "cookie": {
        "name": "Cookie",
        "value": ""
      }
    }
  },
  "body": "{\"properties\":{\"messageRetentionInDays\":1,\"partitionCount\":1,\"partitionIds\":[],\"status\":\"Active\"}}",
  "query": {
    "api-version": "2021-11-01"
  },
  "withCredentials": false,
  "timeout": 0
}
>> Response status code: 200

DELETE:

>> Request: {
  "url": "https://management.azure.com/subscriptions/[REDACTED]/resourceGroups/MyGroup/providers/Microsoft.EventHub/namespaces/MyNamespace/eventhubs/testhub?api-version=2021-11-01",
  "method": "DELETE",
  "headers": {
    "_headersMap": {
      "accept-language": {
        "name": "accept-language",
        "value": "en-US"
      },
      "x-ms-client-request-id": {
        "name": "x-ms-client-request-id",
        "value": "b0e64a5f-fd63-4a9d-a1c3-732dc2d125a7"
      },
      "content-type": {
        "name": "content-type",
        "value": "application/json; charset=utf-8"
      },
      "authorization": {
        "name": "authorization",
        "value": "Bearer <token>"
      },
      "user-agent": {
        "name": "user-agent",
        "value": "ms-rest-js/2.6.1 Node/v14.18.1 OS/(x64-Linux-4.4.0-22000-Microsoft)"
      },
      "cookie": {
        "name": "Cookie",
        "value": ""
      }
    }
  },
  "query": {
    "api-version": "2021-11-01"
  },
  "withCredentials": false,
  "timeout": 0
}
>> Response status code: 200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants