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

[App Config] Migrate to core-v2 #20766

Merged
merged 83 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
605ca61
app-config changes - checkpoint- only 3 test failures
HarshaNalluru Mar 10, 2022
217ac5c
core-rest-pipeline changes
HarshaNalluru Mar 10, 2022
9ace778
test changes
HarshaNalluru Mar 10, 2022
2fb659f
credential fix
HarshaNalluru Mar 10, 2022
c6832d1
skip { timeout: 1 } tests in playback for now
HarshaNalluru Mar 10, 2022
14dec7c
lint:fix
HarshaNalluru Mar 10, 2022
d488e7b
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 11, 2022
3336fb1
expand throttlingRetryStrategy with "retry-after-ms", "x-ms-retry-aft…
HarshaNalluru Mar 12, 2022
44a78ee
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 12, 2022
61ea4b7
Expand test suite with "retry-after-ms" and "x-ms-retry-after-ms"
HarshaNalluru Mar 12, 2022
65017fa
changelog
HarshaNalluru Mar 12, 2022
a03d60d
Merge branch 'harshan/issue/20813' of https://github.com/HarshaNallur…
HarshaNalluru Mar 12, 2022
082e652
lock file
HarshaNalluru Mar 12, 2022
4cc3e4f
rely on core's throttling policy
HarshaNalluru Mar 12, 2022
4f895fe
changelog
HarshaNalluru Mar 12, 2022
1b1fc6c
"version": "1.3.2" -> "version": "1.4.0",
HarshaNalluru Mar 12, 2022
3210497
Update sdk/core/core-rest-pipeline/src/retryStrategies/throttlingRetr…
HarshaNalluru Mar 12, 2022
31ef64e
no new variable
HarshaNalluru Mar 14, 2022
9bfdd96
Merge branch 'harshan/issue/20813' of https://github.com/harshanallur…
HarshaNalluru Mar 14, 2022
eb63952
no internal tag
HarshaNalluru Mar 14, 2022
2752a5b
refactor
HarshaNalluru Mar 14, 2022
f4f55e6
new lines for readability
HarshaNalluru Mar 14, 2022
ea103b9
more refactor
HarshaNalluru Mar 14, 2022
904815d
Update sdk/core/core-rest-pipeline/src/retryStrategies/throttlingRetr…
HarshaNalluru Mar 14, 2022
d98e3db
part of the feedback
HarshaNalluru Mar 14, 2022
91d024b
edge cases and more testing
HarshaNalluru Mar 14, 2022
df951b3
lint
HarshaNalluru Mar 14, 2022
bf5235c
Update sdk/core/core-rest-pipeline/src/retryStrategies/throttlingRetr…
HarshaNalluru Mar 14, 2022
cc0cd1c
Merge branch 'harshan/issue/20813' of https://github.com/HarshaNallur…
HarshaNalluru Mar 14, 2022
1e4aacb
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 14, 2022
8b3577d
format and lock file
HarshaNalluru Mar 14, 2022
3242eaa
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 15, 2022
cb34510
lock file
HarshaNalluru Mar 15, 2022
46c87b3
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 15, 2022
9bb87bc
lock file
HarshaNalluru Mar 15, 2022
d80de39
sarangan feedback
HarshaNalluru Mar 15, 2022
230eb2a
@azure/core-http-compat
HarshaNalluru Mar 15, 2022
e4d3005
remove comments
HarshaNalluru Mar 15, 2022
a158fee
default
HarshaNalluru Mar 15, 2022
f75f448
do not let status code to be 0
HarshaNalluru Mar 15, 2022
563901b
api report
HarshaNalluru Mar 24, 2022
9992dbd
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 24, 2022
2db8df2
lock file
HarshaNalluru Mar 24, 2022
2fb0f52
lock file
HarshaNalluru Mar 31, 2022
f946f1a
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 31, 2022
871a1ee
lock file and formatting
HarshaNalluru Mar 31, 2022
e6c9331
_response is back
HarshaNalluru Mar 31, 2022
28ac591
CHANGELOG
HarshaNalluru Mar 31, 2022
4fc3a00
1.4.0-beta.1
HarshaNalluru Mar 31, 2022
0626ae4
revert
HarshaNalluru Mar 31, 2022
8307ae7
lock file
HarshaNalluru Mar 31, 2022
d0685ec
fixes
HarshaNalluru Mar 31, 2022
108bb0b
add options
HarshaNalluru Mar 31, 2022
4c2a4aa
version automate updater
HarshaNalluru Mar 31, 2022
a71eda9
regenrate after deleting to remove appConfigContext file
HarshaNalluru Mar 31, 2022
ce7994e
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Mar 31, 2022
2aca978
simplify HttpResponseField instances
HarshaNalluru Apr 1, 2022
2a3586c
helper updates
HarshaNalluru Apr 1, 2022
b7bd3a7
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Apr 6, 2022
0f93d14
assertResponse as suggested by Jeff
HarshaNalluru Apr 6, 2022
fe4e4a0
fix tests
HarshaNalluru Apr 6, 2022
dd92dc8
fix tests
HarshaNalluru Apr 6, 2022
d183395
changes in core-compat
HarshaNalluru Apr 7, 2022
b7f7b7d
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Apr 7, 2022
71843c9
status code is never undefined
HarshaNalluru Apr 7, 2022
e6849fc
export utils
HarshaNalluru Apr 7, 2022
6329aa2
api report
HarshaNalluru Apr 7, 2022
43f426c
api report
HarshaNalluru Apr 7, 2022
a91ea11
format
HarshaNalluru Apr 7, 2022
8eec27a
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Apr 7, 2022
ac7744f
lock filke
HarshaNalluru Apr 7, 2022
22a7855
changelog
HarshaNalluru Apr 7, 2022
ea17a2b
TransferProgressEvent
HarshaNalluru Apr 7, 2022
e40a696
1.3.0
HarshaNalluru Apr 7, 2022
968de64
feedback address
HarshaNalluru Apr 7, 2022
43ec708
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Apr 7, 2022
95babed
Update sdk/appconfiguration/app-configuration/src/internal/helpers.ts
HarshaNalluru Apr 7, 2022
ae89abb
Update sdk/appconfiguration/app-configuration/src/internal/synctokenp…
HarshaNalluru Apr 7, 2022
0020980
unneeded excess code
HarshaNalluru Apr 7, 2022
34f419d
Merge branch 'harshan/app-config/15809' of https://github.com/harshan…
HarshaNalluru Apr 7, 2022
9b3889a
don't throw
HarshaNalluru Apr 7, 2022
23457e7
remove toUpperCase
HarshaNalluru Apr 7, 2022
0ec8eb4
format
HarshaNalluru Apr 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,690 changes: 1,916 additions & 1,774 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions sdk/appconfiguration/app-configuration/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Release History

## 1.3.2 (Unreleased)
## 1.4.0-beta.1 (Unreleased)

### Features Added

- Migrated from using `@azure/core-http` to depend on newer version of Core libraries `@azure/core-client` and `@azure/core-rest-pipeline` which bring better maintainability and performance. [#20766](https://github.com/Azure/azure-sdk-for-js/pull/20766). See [Azure Core v1 vs v2](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-rest-pipeline/documentation/core2.md) for more on the difference and benefits of the move.
- As part of the migration to `@azure/core-client` and `@azure/core-rest-pipeline`,
through the operation options, the methods such as `AppConfgurationClient#addConfigurationSetting` can take a callback (`onResponse`) to access the HTTP response. See [Change to the \_response property](https://github.com/Azure/autorest.typescript/wiki/%60core-http%60-dependency-migration-to-%60core-client%60-%60core-rest-pipeline%60#change-to-the-_response-property).

### Breaking Changes

### Bugs Fixed
Expand Down Expand Up @@ -101,8 +105,8 @@ This release marks the general availability of the `@azure/app-configuration` pa
```typescript
new AppConfigurationClient(connectionString, {
userAgentOptions: {
userAgentPrefix: "MyUserAgent"
}
userAgentPrefix: "MyUserAgent",
},
});
```

Expand Down Expand Up @@ -158,11 +162,11 @@ In previous previews:
await client.getConfigurationSetting("MyKey", { label: "MyLabel" });
await client.addConfigurationSetting("MyKey", {
label: "MyLabel",
value: "MyValue"
value: "MyValue",
});
await client.setConfigurationSetting("MyKey", {
label: "MyLabel",
value: "MyValue"
value: "MyValue",
});
await client.deleteConfigurationSetting("MyKey", { label: "MyLabel" });
```
Expand All @@ -175,12 +179,12 @@ await client.getConfigurationSetting({ key: "MyKey", label: "MyLabel" });
await client.addConfigurationSetting({
key: "MyKey",
label: "MyLabel",
value: "MyValue"
value: "MyValue",
});
await client.setConfigurationSetting({
key: "MyKey",
label: "MyLabel",
value: "MyValue"
value: "MyValue",
});
await client.deleteConfigurationSetting({ key: "MyKey", label: "MyLabel" });
```
Expand Down
12 changes: 10 additions & 2 deletions sdk/appconfiguration/app-configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/app-configuration",
"author": "Microsoft Corporation",
"description": "An isomorphic client library for the Azure App Configuration service.",
"version": "1.3.2",
"version": "1.4.0-beta.1",
"sdk-type": "client",
"keywords": [
"node",
Expand Down Expand Up @@ -81,14 +81,20 @@
{
"path": "src/generated/src/appConfigurationContext.ts",
"prefix": "packageVersion"
},
{
"path": "swagger/swagger.md",
"prefix": "package-version"
}
]
},
"dependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/core-asynciterator-polyfill": "^1.0.0",
"@azure/core-http": "^2.0.0",
"@azure/core-client": "^1.5.0",
"@azure/core-http-compat": "^1.2.0",
"@azure/core-paging": "^1.1.1",
"@azure/core-rest-pipeline": "^1.6.0",
"@azure/core-tracing": "1.0.0-preview.13",
"@azure/core-auth": "^1.3.0",
"tslib": "^2.2.0"
Expand All @@ -110,6 +116,7 @@
"@types/mocha": "^7.0.2",
"@types/node": "^12.0.0",
"@types/sinon": "^9.0.4",
"@types/uuid": "^8.3.4",
"chai": "^4.2.0",
"dotenv": "^8.2.0",
"eslint": "^7.15.0",
Expand Down Expand Up @@ -139,6 +146,7 @@
"ts-node": "^10.0.0",
"typescript": "~4.2.0",
"uglify-js": "^3.4.9",
"uuid": "^8.3.0",
"cross-env": "^7.0.2"
},
"//sampleConfiguration": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

/// <reference lib="esnext.asynciterable" />

import { HttpResponse } from '@azure/core-http';
import { OperationOptions } from '@azure/core-http';
import { CommonClientOptions } from '@azure/core-client';
import { CompatResponse } from '@azure/core-http-compat';
import { OperationOptions } from '@azure/core-client';
import { PagedAsyncIterableIterator } from '@azure/core-paging';
import { TokenCredential } from '@azure/core-auth';
import { UserAgentOptions } from '@azure/core-http';

// @public
export interface AddConfigurationSettingOptions extends OperationOptions {
Expand Down Expand Up @@ -38,9 +38,7 @@ export class AppConfigurationClient {
}

// @public
export interface AppConfigurationClientOptions {
retryOptions?: RetryOptions;
userAgentOptions?: UserAgentOptions;
export interface AppConfigurationClientOptions extends CommonClientOptions {
}

// @public
Expand Down Expand Up @@ -124,7 +122,7 @@ export interface HttpOnlyIfUnchangedField {

// @public
export interface HttpResponseField<HeadersT> {
_response: HttpResponse & {
_response: CompatResponse & {
parsedHeaders: HeadersT;
bodyAsText: string;
};
Expand Down
83 changes: 36 additions & 47 deletions sdk/appconfiguration/app-configuration/src/appConfigCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,44 @@
// Licensed under the MIT license.

import {
ServiceClientCredentials,
WebResource,
URLBuilder,
WebResourceLike,
} from "@azure/core-http";
PipelinePolicy,
PipelineRequest,
PipelineResponse,
SendRequest,
} from "@azure/core-rest-pipeline";
import { sha256Digest, sha256Hmac } from "./internal/cryptoHelpers";

/**
* @internal
* Create an HTTP pipeline policy to authenticate a request
* using an `AzureKeyCredential` for AppConfig.
*/
export class AppConfigCredential implements ServiceClientCredentials {
private credential: string;
private secret: string;

constructor(credential: string, secret: string) {
this.credential = credential;
this.secret = secret;
}

/**
* Signs a request with the values provided in the credential and secret parameter.
*
* @param webResource - The WebResource to be signed.
* @returns The signed request object.
*/
async signRequest(webResource: WebResourceLike): Promise<WebResource> {
const verb = webResource.method.toUpperCase();
const utcNow = new Date().toUTCString();

const contentHash = await sha256Digest(webResource.body || "");

const signedHeaders = "x-ms-date;host;x-ms-content-sha256";

const url = URLBuilder.parse(webResource.url);
const query = url.getQuery();
const urlPathAndQuery = `${url.getPath()}${query ? "?" + query : ""}`;

const stringToSign = `${verb}\n${urlPathAndQuery}\n${utcNow};${url.getHost()};${contentHash}`;

const signature = await sha256Hmac(this.secret, stringToSign);

webResource.headers.set("x-ms-date", utcNow);
webResource.headers.set("x-ms-content-sha256", contentHash);
// Syntax for Authorization header
// Reference - https://docs.microsoft.com/en-us/azure/azure-app-configuration/rest-api-authentication-hmac#syntax
webResource.headers.set(
"Authorization",
`HMAC-SHA256 Credential=${this.credential}&SignedHeaders=${signedHeaders}&Signature=${signature}`
);
return webResource;
}
export function createAppConfigKeyCredentialPolicy(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: just appConfigKeyCredentialPolicy()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

credential: string,
secret: string
): PipelinePolicy {
return {
name: "AppConfigKeyCredentialPolicy",
async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {
const verb = request.method.toUpperCase();
HarshaNalluru marked this conversation as resolved.
Show resolved Hide resolved
const utcNow = new Date().toUTCString();
const contentHash = await sha256Digest(request.body?.toString() || "");
const signedHeaders = "x-ms-date;host;x-ms-content-sha256";
const url = new URL(request.url);
const query = url.search;
const urlPathAndQuery = query ? `${url.pathname}${query}` : url.pathname;
const stringToSign = `${verb}\n${urlPathAndQuery}\n${utcNow};${url.host};${contentHash}`;
const signature = await sha256Hmac(secret, stringToSign);

request.headers.set("x-ms-date", utcNow);
request.headers.set("x-ms-content-sha256", contentHash);
// Syntax for Authorization header
// Reference - https://docs.microsoft.com/en-us/azure/azure-app-configuration/rest-api-authentication-hmac#syntax
request.headers.set(
"Authorization",
`HMAC-SHA256 Credential=${credential}&SignedHeaders=${signedHeaders}&Signature=${signature}`
);

return next(request);
},
};
}
Loading