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

Use Create Table Operation with Azure SDK for JS doesn't access Azurite #12753

Closed
zzhxiaofeng opened this issue Dec 3, 2020 · 9 comments
Closed
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. needs-team-triage Workflow: This issue needs the team to triage. Tables test-manual-pass

Comments

@zzhxiaofeng
Copy link
Contributor

  • Package Name: @azure/data-tables
  • Package Version: 1.0.0-beta.3
  • NodeJS: v12.18.0
  • Typescript: v3.9.5

Error Description:
When use Create Table Operation, request URL which is constructed in Azure SDK for JS can not access Azurite. The reason is the request URL for Azurite is different from the one of an Azure storage account.
In Azurite, request URL of Create Table Operation constructed is shown as following:

https://127.0.0.1:10002/<account-name>/Tables

In Azure SDK for JS, request URL which is used to access azurite in create table operation is shown as following:

https://127.0.0.1:10002/<account-name>

It use <account-name> as path and doesn't use Tables which is the path of Create Table Operation.

Error Track:
The code for storage table request URL constructed in Azure SDK for JS as following:
https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/tables/data-tables/src/generated/operations/table.ts#L81
Screenshot 2020-12-02 142723
When using Create Table operation with Azurite endpoint(https://127.0.0.1:10002/devstoreaccount1), the handler method in Azure SDK for JS put 127.0.0.1 as host, 10002 as port, /devstoreaccount1 as path.
https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-http/src/url.ts#L368
Screenshot 2020-12-03 095214

Expected Behavior
When using Create Table Operation, the request URL which is constructed in Azure SDK for JS can access azurite.

@jongio for notification.

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 3, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 3, 2020
@tzhanl tzhanl added needs-team-triage Workflow: This issue needs the team to triage. Client This issue points to a problem in the data-plane of the library. labels Dec 3, 2020
@joheredi
Copy link
Member

joheredi commented Dec 10, 2020

@zzhxiaofeng thanks for reporting this issue. Is this happening for all operations or only for create table?

Also, would you mind sharing a snippet of your test code which reproduces this issue please?

@zzhxiaofeng
Copy link
Contributor Author

@joheredi Ok, I just find this issue when use create table operation in Azurite.
the code to reproduce is shown as following:

import { TableClient } from "@azure/data-tables";
import * as assert from "assert"
async function main() {
   const tableClient = await TableClient.fromConnectionString("<Azurite-https-connectionString>", "<table-name>");
   try{
      await tableClient.create();
   }catch(err){
      assert.ok(error);
   }
}
main();

@joheredi
Copy link
Member

I've filed an issue in core-http #13159 to track the fundamental issue. Meanwhile, I'm currently investigating a way to work around this limitation in the SDK side

@joheredi
Copy link
Member

Thanks for reporting this issue, a fix has been merged and a new version released. Please install the latest version of @azure/data-tables and let me know if you see any issues.

npm install @azure/data-tables@latest

Sample to create a client to test with Azurite:

const tableService = TableClient.fromConnectionString('UseDevelopmentStorage=true', 'testTable');

@zzhxiaofeng
Copy link
Contributor Author

@joheredi Thank you for resolve the issue. But the latest version of @azure/data-tables just support use http connection string to access Azurite. Can you update the code and make @azure/data-tables to support use https connection string of Azurite?

@joheredi
Copy link
Member

@zzhxiaofeng, UseDevelopmentStorage=true shortcut is meant to be used in the most basic scenario. For more advanced scenarios such as using https, custom host or accountId you should be able to do this by explicitly setting the custom values. For example:

const credentials = new TablesSharedKeyCredential("devstoreaccount1", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==")
const client = new TableClient("https://localhost:10002/devstoreaccount1", "testTable", credentials)

Please let me know if this works for you

@zzhxiaofeng
Copy link
Contributor Author

@joheredi Yes, it works. I'm sorry to waste your time.

@joheredi
Copy link
Member

No waste at all, thanks for reporting the issue! I'm happy to hear that your problem got resolved!

openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Mar 8, 2021
@v-xuto
Copy link
Member

v-xuto commented May 17, 2021

azsdk-azurite

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. needs-team-triage Workflow: This issue needs the team to triage. Tables test-manual-pass
Projects
None yet
Development

No branches or pull requests

4 participants