Skip to content

Commit

Permalink
Revert "[storage] add fromConnectString to DataLakeServiceClient (#13420
Browse files Browse the repository at this point in the history
)"

This reverts commit bfa1f92.
  • Loading branch information
ljian3377 authored Feb 7, 2021
1 parent bfa1f92 commit c30a3b0
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 243 deletions.
1 change: 0 additions & 1 deletion sdk/storage/storage-file-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- Fixed a bug where `generateDataLakeSASQueryParameters()` won't correctly set the resource type if `DataLakeSASSignatureValues.permissions` is not specified. Fixed issue [13223](https://github.com/Azure/azure-sdk-for-js/issues/13223).
- Fixed a compile failure due to "Can't resolve 'crypto'" in Angular. [Issue #13267](https://github.com/Azure/azure-sdk-for-js/issues/13267).
- The `"Unclosed root tag"` XML parser error is now retriable. [PR #13076](https://github.com/Azure/azure-sdk-for-js/pull/13076).
- Added `fromConnectionString` to `DataLakeServiceClient` to support construction from a connection string. Fixed bug [13396](https://github.com/Azure/azure-sdk-for-js/issues/13396).

## 12.3.0 (2021-01-12)

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ export interface DataLakeSASSignatureValues {
export class DataLakeServiceClient extends StorageClient {
constructor(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions);
constructor(url: string, pipeline: Pipeline);
static fromConnectionString(connectionString: string, options?: StoragePipelineOptions): DataLakeServiceClient;
generateAccountSasUrl(expiresOn?: Date, permissions?: AccountSASPermissions, resourceTypes?: string, options?: ServiceGenerateAccountSasUrlOptions): string;
getFileSystemClient(fileSystemName: string): DataLakeFileSystemClient;
getUserDelegationKey(startsOn: Date, expiresOn: Date, options?: ServiceGetUserDelegationKeyOptions): Promise<ServiceGetUserDelegationKeyResponse>;
Expand Down
51 changes: 3 additions & 48 deletions sdk/storage/storage-file-datalake/src/DataLakeServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import "@azure/core-paging";

import { getDefaultProxySettings, isNode, TokenCredential } from "@azure/core-http";
import { TokenCredential } from "@azure/core-http";
import { PagedAsyncIterableIterator } from "@azure/core-paging";
import { BlobServiceClient } from "@azure/storage-blob";

Expand All @@ -18,13 +18,9 @@ import {
} from "./models";
import { Pipeline, StoragePipelineOptions, newPipeline } from "./Pipeline";
import { StorageClient } from "./StorageClient";
import {
appendToURLPath,
appendToURLQuery,
extractConnectionStringParts
} from "./utils/utils.common";
import { appendToURLPath, appendToURLQuery } from "./utils/utils.common";
import { createSpan } from "./utils/tracing";
import { toDfsEndpointUrl, toFileSystemPagedAsyncIterableIterator } from "./transforms";
import { toFileSystemPagedAsyncIterableIterator } from "./transforms";
import { ServiceGetUserDelegationKeyOptions, ServiceGetUserDelegationKeyResponse } from "./models";
import { CanonicalCode } from "@opentelemetry/api";
import { AccountSASPermissions } from "./sas/AccountSASPermissions";
Expand Down Expand Up @@ -52,47 +48,6 @@ export class DataLakeServiceClient extends StorageClient {
*/
private blobServiceClient: BlobServiceClient;

/**
*
* Creates an instance of DataLakeServiceClient from connection string.
*
* @param {string} connectionString Account connection string or a SAS connection string of an Azure storage account.
* [ Note - Account connection string can only be used in NODE.JS runtime. ]
* Account connection string example -
* `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`
* SAS connection string example -
* `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`
* @param {StoragePipelineOptions} [options] Optional. Options to configure the HTTP pipeline.
* @memberof DataLakeServiceClient
*/
public static fromConnectionString(connectionString: string, options?: StoragePipelineOptions) {
options = options || {};
const extractedCreds = extractConnectionStringParts(connectionString);
if (extractedCreds.kind === "AccountConnString") {
if (isNode) {
const sharedKeyCredential = new StorageSharedKeyCredential(
extractedCreds.accountName!,
extractedCreds.accountKey
);
options.proxyOptions = getDefaultProxySettings(extractedCreds.proxyUri);
const pipeline = newPipeline(sharedKeyCredential, options);
return new DataLakeServiceClient(toDfsEndpointUrl(extractedCreds.url), pipeline);
} else {
throw new Error("Account connection string is only supported in Node.js environment");
}
} else if (extractedCreds.kind === "SASConnString") {
const pipeline = newPipeline(new AnonymousCredential(), options);
return new DataLakeServiceClient(
toDfsEndpointUrl(extractedCreds.url) + "?" + extractedCreds.accountSas,
pipeline
);
} else {
throw new Error(
"Connection string must be either an Account connection string or a SAS connection string"
);
}
}

/**
* Creates an instance of DataLakeServiceClient from url.
*
Expand Down
35 changes: 0 additions & 35 deletions sdk/storage/storage-file-datalake/test/node/serviceclient.spec.ts

This file was deleted.

22 changes: 1 addition & 21 deletions sdk/storage/storage-file-datalake/test/serviceclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import * as assert from "assert";
import * as dotenv from "dotenv";

import { DataLakeServiceClient, ServiceListFileSystemsSegmentResponse } from "../src";
import {
getDataLakeServiceClient,
getSASConnectionStringFromEnvironment,
getTokenDataLakeServiceClient,
recorderEnvSetup
} from "./utils";
import { getDataLakeServiceClient, getTokenDataLakeServiceClient, recorderEnvSetup } from "./utils";

dotenv.config();

Expand Down Expand Up @@ -351,19 +346,4 @@ describe("DataLakeServiceClient", () => {
assert.notDeepStrictEqual(response.signedObjectId, undefined);
assert.notDeepStrictEqual(response.signedExpiresOn, undefined);
});

it("can be created from SASConnString", async () => {
const newClient = DataLakeServiceClient.fromConnectionString(
getSASConnectionStringFromEnvironment(),
{
retryOptions: {
maxTries: 1
}
}
);

const listIter = newClient.listFileSystems();
await listIter.next();
assert.ok(newClient.url.includes("dfs"));
});
});
5 changes: 0 additions & 5 deletions sdk/storage/storage-file-datalake/test/utils/index.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,3 @@ export function getBrowserFile(name: string, size: number): File {
file.name = name;
return file;
}

export function getSASConnectionStringFromEnvironment(): string {
const env = (window as any).__env__;
return `BlobEndpoint=https://${env.DFS_ACCOUNT_NAME}.blob.core.windows.net/;QueueEndpoint=https://${env.DFS_ACCOUNT_NAME}.queue.core.windows.net/;FileEndpoint=https://${env.DFS_ACCOUNT_NAME}.file.core.windows.net/;TableEndpoint=https://${env.DFS_ACCOUNT_NAME}.table.core.windows.net/;SharedAccessSignature=${env.DFS_ACCOUNT_SAS}`;
}
45 changes: 0 additions & 45 deletions sdk/storage/storage-file-datalake/test/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ import { DataLakeServiceClient } from "../../src/DataLakeServiceClient";
import { newPipeline, StoragePipelineOptions } from "../../src/Pipeline";
import { getUniqueName, SimpleTokenCredential } from "./testutils.common";
import {
AccountSASPermissions,
AccountSASResourceTypes,
AccountSASServices,
DataLakeFileSystemClient,
DataLakeSASSignatureValues,
generateAccountSASQueryParameters,
generateDataLakeSASQueryParameters
} from "../../src";
import { extractConnectionStringParts } from "../../src/utils/utils.common";

dotenv.config();

Expand Down Expand Up @@ -245,43 +240,3 @@ export async function createRandomLocalFile(
ws.on("error", reject);
});
}

export function getConnectionStringFromEnvironment(accountType: string = "DFS_"): string {
const connectionStringEnvVar = `${accountType}STORAGE_CONNECTION_STRING`;
const connectionString = process.env[connectionStringEnvVar];

if (!connectionString) {
throw new Error(`${connectionStringEnvVar} environment variables not specified.`);
}

return connectionString;
}

export function getSASConnectionStringFromEnvironment(): string {
const now = new Date();
now.setMinutes(now.getMinutes() - 5); // Skip clock skew with server

const tmr = new Date();
tmr.setDate(tmr.getDate() + 1);

const sharedKeyCredential = getGenericCredential("DFS_");

const sas = generateAccountSASQueryParameters(
{
expiresOn: tmr,
permissions: AccountSASPermissions.parse("rwdlacup"),
resourceTypes: AccountSASResourceTypes.parse("sco").toString(),
services: AccountSASServices.parse("btqf").toString()
},
sharedKeyCredential as StorageSharedKeyCredential
).toString();

const blobEndpoint = extractConnectionStringParts(getConnectionStringFromEnvironment()).url;
return `BlobEndpoint=${blobEndpoint}/;QueueEndpoint=${blobEndpoint.replace(
".blob.",
".queue."
)}/;FileEndpoint=${blobEndpoint.replace(
".queue.",
".file."
)}/;TableEndpoint=${blobEndpoint.replace(".queue.", ".table.")}/;SharedAccessSignature=${sas}`;
}
2 changes: 1 addition & 1 deletion sdk/storage/storage-file-share/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const { ShareServiceClient } = require("@azure/storage-file-share");

const connStr = "<connection string>";

const shareServiceClient = ShareServiceClient.fromConnectionString(connStr);
const ShareServiceClient = ShareServiceClient.fromConnectionString(connStr);
```

#### with `StorageSharedKeyCredential`
Expand Down

0 comments on commit c30a3b0

Please sign in to comment.