Skip to content

Commit b6b17fe

Browse files
author
SDKAuto
committed
CodeGen from PR 15050 in Azure/azure-rest-api-specs
Merge af44661236b6a92f7eb938f69d3b09c1bfb032f5 into b5b3ae9a081535b4dabce52a1136eece3e2d469f
1 parent 899fc0a commit b6b17fe

14 files changed

+833
-1101
lines changed

sdk/signalr/arm-signalr/README.md

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,97 @@
11
## Azure SignalRManagementClient SDK for JavaScript
22

3-
This package contains an isomorphic SDK for SignalRManagementClient.
3+
This package contains an isomorphic SDK (runs both in node.js and in browsers) for SignalRManagementClient.
44

55
### Currently supported environments
66

7-
- Node.js version 6.x.x or higher
8-
- Browser JavaScript
7+
- [LTS versions of Node.js](https://nodejs.org/about/releases/)
8+
- Latest versions of Safari, Chrome, Edge and Firefox.
99

10-
### How to Install
10+
### Prerequisites
1111

12+
You must have an [Azure subscription](https://azure.microsoft.com/free/).
13+
14+
### How to install
15+
16+
To use this SDK in your project, you will need to install two packages.
17+
- `@azure/arm-signalr` that contains the client.
18+
- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory.
19+
20+
Install both packages using the below command:
1221
```bash
13-
npm install @azure/arm-signalr
22+
npm install --save @azure/arm-signalr @azure/identity
1423
```
24+
> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features.
25+
If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options.
1526

1627
### How to use
1728

18-
#### nodejs - client creation and list operations as an example written in TypeScript.
29+
- If you are writing a client side browser application,
30+
- Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions.
31+
- Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below.
32+
- If you are writing a server side application,
33+
- [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples)
34+
- Complete the set up steps required by the credential if any.
35+
- Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below.
1936

20-
##### Install @azure/ms-rest-nodeauth
21-
22-
- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.
23-
24-
```bash
25-
npm install @azure/ms-rest-nodeauth@"^3.0.0"
26-
```
37+
In the below samples, we pass the credential and the Azure subscription id to instantiate the client.
38+
Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started.
39+
#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript.
2740

2841
##### Sample code
2942

30-
While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package
31-
32-
```typescript
33-
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
43+
```javascript
44+
const { DefaultAzureCredential } = require("@azure/identity");
3445
const { SignalRManagementClient } = require("@azure/arm-signalr");
3546
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
3647

37-
msRestNodeAuth
38-
.interactiveLogin()
39-
.then((creds) => {
40-
const client = new SignalRManagementClient(creds, subscriptionId);
41-
client.operations.list().then((result) => {
42-
console.log("The result is:");
43-
console.log(result);
44-
});
45-
})
46-
.catch((err) => {
47-
console.error(err);
48-
});
48+
// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples
49+
// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead.
50+
const creds = new DefaultAzureCredential();
51+
const client = new SignalRManagementClient(creds, subscriptionId);
52+
client.operations.list().then((result) => {
53+
console.log("The result is:");
54+
console.log(result);
55+
}).catch((err) => {
56+
console.log("An error occurred:");
57+
console.error(err);
58+
});
4959
```
5060

51-
#### browser - Authentication, client creation and list operations as an example written in JavaScript.
52-
53-
##### Install @azure/ms-rest-browserauth
61+
#### browser - Authentication, client creation, and list operations as an example written in JavaScript.
5462

55-
```bash
56-
npm install @azure/ms-rest-browserauth
57-
```
63+
In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser.
64+
- See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser.
65+
- Note down the client Id from the previous step and use it in the browser sample below.
5866

5967
##### Sample code
6068

61-
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.
62-
6369
- index.html
6470

6571
```html
6672
<!DOCTYPE html>
6773
<html lang="en">
6874
<head>
6975
<title>@azure/arm-signalr sample</title>
70-
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
7176
<script src="node_modules/@azure/ms-rest-azure-js/dist/msRestAzure.js"></script>
72-
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
77+
<script src="node_modules/@azure/identity/dist/index.js"></script>
7378
<script src="node_modules/@azure/arm-signalr/dist/arm-signalr.js"></script>
7479
<script type="text/javascript">
7580
const subscriptionId = "<Subscription_Id>";
76-
const authManager = new msAuth.AuthManager({
81+
// Create credentials using the `@azure/identity` package.
82+
// Please note that you can also use credentials from the `@azure/ms-rest-browserauth` package instead.
83+
const credential = new InteractiveBrowserCredential(
84+
{
7785
clientId: "<client id for your Azure AD app>",
7886
tenant: "<optional tenant for your organization>"
7987
});
80-
authManager.finalizeLogin().then((res) => {
81-
if (!res.isLoggedIn) {
82-
// may cause redirects
83-
authManager.login();
84-
}
85-
const client = new Azure.ArmSignalr.SignalRManagementClient(res.creds, subscriptionId);
86-
client.operations
87-
.list()
88-
.then((result) => {
89-
console.log("The result is:");
90-
console.log(result);
91-
})
92-
.catch((err) => {
93-
console.log("An error occurred:");
94-
console.error(err);
95-
});
88+
const client = new Azure.ArmSignalr.SignalRManagementClient(creds, subscriptionId);
89+
client.operations.list().then((result) => {
90+
console.log("The result is:");
91+
console.log(result);
92+
}).catch((err) => {
93+
console.log("An error occurred:");
94+
console.error(err);
9695
});
9796
</script>
9897
</head>

sdk/signalr/arm-signalr/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"description": "SignalRManagementClient Library with typescript type definitions for node.js and browser.",
55
"version": "4.0.0",
66
"dependencies": {
7-
"@azure/ms-rest-azure-js": "^2.0.1",
8-
"@azure/ms-rest-js": "^2.0.4",
7+
"@azure/ms-rest-azure-js": "^2.1.0",
8+
"@azure/ms-rest-js": "^2.2.0",
9+
"@azure/core-auth": "^1.1.4",
910
"tslib": "^1.10.0"
1011
},
1112
"keywords": [
@@ -20,13 +21,13 @@
2021
"module": "./esm/signalRManagementClient.js",
2122
"types": "./esm/signalRManagementClient.d.ts",
2223
"devDependencies": {
23-
"typescript": "^3.5.3",
24+
"typescript": "^3.6.0",
2425
"rollup": "^1.18.0",
2526
"rollup-plugin-node-resolve": "^5.2.0",
2627
"rollup-plugin-sourcemaps": "^0.4.2",
2728
"uglify-js": "^3.6.0"
2829
},
29-
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/signalr/arm-signalr",
30+
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/signalr/arm-signalr",
3031
"repository": {
3132
"type": "git",
3233
"url": "https://github.com/Azure/azure-sdk-for-js.git"

sdk/signalr/arm-signalr/rollup.config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import sourcemaps from "rollup-plugin-sourcemaps";
77
*/
88
const config = {
99
input: "./esm/signalRManagementClient.js",
10-
external: ["@azure/ms-rest-js", "@azure/ms-rest-azure-js"],
10+
external: [
11+
"@azure/ms-rest-js",
12+
"@azure/ms-rest-azure-js"
13+
],
1114
output: {
1215
file: "./dist/arm-signalr.js",
1316
format: "umd",
@@ -25,7 +28,10 @@ const config = {
2528
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
2629
*/`
2730
},
28-
plugins: [nodeResolve({ mainFields: ["module", "main"] }), sourcemaps()]
31+
plugins: [
32+
nodeResolve({ mainFields: ['module', 'main'] }),
33+
sourcemaps()
34+
]
2935
};
3036

3137
export default config;

0 commit comments

Comments
 (0)