Skip to content

Commit e562127

Browse files
colawwjdw511214992ramya-rao-a
authored
Arm recoveryservicesbackup v4 (Azure#15531)
* arm-recoveryservicesbackup-v4 * arm-recoveryservicesbackup-v4 * update readme * Update sdk/recoveryservicesbackup/arm-recoveryservicesbackup/README.md Co-authored-by: Ramya Rao <ramya.rao.a@outlook.com> Co-authored-by: Wei Dong <40835867+dw511214992@users.noreply.github.com> Co-authored-by: Ramya Rao <ramya.rao.a@outlook.com>
1 parent 6eca5bc commit e562127

File tree

114 files changed

+14268
-5233
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+14268
-5233
lines changed

sdk/recoveryservicesbackup/arm-recoveryservicesbackup/LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2020 Microsoft
3+
Copyright (c) 2021 Microsoft
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

sdk/recoveryservicesbackup/arm-recoveryservicesbackup/README.md

Lines changed: 65 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,115 @@
11
## Azure RecoveryServicesBackupClient SDK for JavaScript
22

3-
This package contains an isomorphic SDK for RecoveryServicesBackupClient.
3+
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for RecoveryServicesBackupClient.
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
11+
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+
18+
- `@azure/arm-recoveryservicesbackup` that contains the client.
19+
- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory.
20+
21+
Install both packages using the below command:
1122

1223
```bash
13-
npm install @azure/arm-recoveryservicesbackup
24+
npm install --save @azure/arm-recoveryservicesbackup @azure/identity
1425
```
1526

27+
> **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.
28+
> 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.
29+
1630
### How to use
1731

18-
#### nodejs - Authentication, client creation and get privateEndpointConnection as an example written in TypeScript.
32+
- If you are writing a client side browser application,
33+
- 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.
34+
- 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.
35+
- If you are writing a server side application,
36+
- [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples)
37+
- Complete the set up steps required by the credential if any.
38+
- Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below.
1939

20-
##### Install @azure/ms-rest-nodeauth
40+
In the below samples, we pass the credential and the Azure subscription id to instantiate the client.
41+
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.
2142

22-
- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.
23-
```bash
24-
npm install @azure/ms-rest-nodeauth@"^3.0.0"
25-
```
43+
#### nodejs - Authentication, client creation, and get backupResourceVaultConfigs as an example written in JavaScript.
2644

2745
##### Sample code
2846

29-
```typescript
30-
import * as msRest from "@azure/ms-rest-js";
31-
import * as msRestAzure from "@azure/ms-rest-azure-js";
32-
import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
33-
import { RecoveryServicesBackupClient, RecoveryServicesBackupModels, RecoveryServicesBackupMappers } from "@azure/arm-recoveryservicesbackup";
47+
```javascript
48+
const { DefaultAzureCredential } = require("@azure/identity");
49+
const { RecoveryServicesBackupClient } = require("@azure/arm-recoveryservicesbackup");
3450
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
3551

36-
msRestNodeAuth.interactiveLogin().then((creds) => {
37-
const client = new RecoveryServicesBackupClient(creds, subscriptionId);
38-
const vaultName = "testvaultName";
39-
const resourceGroupName = "testresourceGroupName";
40-
const privateEndpointConnectionName = "testprivateEndpointConnectionName";
41-
client.privateEndpointConnection.get(vaultName, resourceGroupName, privateEndpointConnectionName).then((result) => {
52+
// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples
53+
// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead.
54+
const creds = new DefaultAzureCredential();
55+
const client = new RecoveryServicesBackupClient(creds, subscriptionId);
56+
const vaultName = "testvaultName";
57+
const resourceGroupName = "testresourceGroupName";
58+
client.backupResourceVaultConfigs
59+
.get(vaultName, resourceGroupName)
60+
.then((result) => {
4261
console.log("The result is:");
4362
console.log(result);
63+
})
64+
.catch((err) => {
65+
console.log("An error occurred:");
66+
console.error(err);
4467
});
45-
}).catch((err) => {
46-
console.error(err);
47-
});
4868
```
4969

50-
#### browser - Authentication, client creation and get privateEndpointConnection as an example written in JavaScript.
70+
#### browser - Authentication, client creation, and get backupResourceVaultConfigs as an example written in JavaScript.
5171

52-
##### Install @azure/ms-rest-browserauth
72+
In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser.
5373

54-
```bash
55-
npm install @azure/ms-rest-browserauth
56-
```
74+
- 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.
75+
- Note down the client Id from the previous step and use it in the browser sample below.
5776

5877
##### Sample code
5978

60-
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.
61-
6279
- index.html
80+
6381
```html
6482
<!DOCTYPE html>
6583
<html lang="en">
6684
<head>
6785
<title>@azure/arm-recoveryservicesbackup sample</title>
68-
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
6986
<script src="node_modules/@azure/ms-rest-azure-js/dist/msRestAzure.js"></script>
70-
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
87+
<script src="node_modules/@azure/identity/dist/index.js"></script>
7188
<script src="node_modules/@azure/arm-recoveryservicesbackup/dist/arm-recoveryservicesbackup.js"></script>
7289
<script type="text/javascript">
7390
const subscriptionId = "<Subscription_Id>";
74-
const authManager = new msAuth.AuthManager({
91+
// Create credentials using the `@azure/identity` package.
92+
// Please note that you can also use credentials from the `@azure/ms-rest-browserauth` package instead.
93+
const credential = new InteractiveBrowserCredential({
7594
clientId: "<client id for your Azure AD app>",
7695
tenant: "<optional tenant for your organization>"
7796
});
78-
authManager.finalizeLogin().then((res) => {
79-
if (!res.isLoggedIn) {
80-
// may cause redirects
81-
authManager.login();
82-
}
83-
const client = new Azure.ArmRecoveryservicesbackup.RecoveryServicesBackupClient(res.creds, subscriptionId);
84-
const vaultName = "testvaultName";
85-
const resourceGroupName = "testresourceGroupName";
86-
const privateEndpointConnectionName = "testprivateEndpointConnectionName";
87-
client.privateEndpointConnection.get(vaultName, resourceGroupName, privateEndpointConnectionName).then((result) => {
97+
const client = new Azure.ArmRecoveryservicesbackup.RecoveryServicesBackupClient(
98+
creds,
99+
subscriptionId
100+
);
101+
const vaultName = "testvaultName";
102+
const resourceGroupName = "testresourceGroupName";
103+
client.backupResourceVaultConfigs
104+
.get(vaultName, resourceGroupName)
105+
.then((result) => {
88106
console.log("The result is:");
89107
console.log(result);
90-
}).catch((err) => {
108+
})
109+
.catch((err) => {
91110
console.log("An error occurred:");
92111
console.error(err);
93112
});
94-
});
95113
</script>
96114
</head>
97115
<body></body>

sdk/recoveryservicesbackup/arm-recoveryservicesbackup/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"name": "@azure/arm-recoveryservicesbackup",
33
"author": "Microsoft Corporation",
44
"description": "RecoveryServicesBackupClient Library with typescript type definitions for node.js and browser.",
5-
"version": "6.1.0",
5+
"version": "7.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,7 +21,7 @@
2021
"module": "./esm/recoveryServicesBackupClient.js",
2122
"types": "./esm/recoveryServicesBackupClient.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",

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import sourcemaps from "rollup-plugin-sourcemaps";
77
*/
88
const config = {
99
input: "./esm/recoveryServicesBackupClient.js",
10-
external: [
11-
"@azure/ms-rest-js",
12-
"@azure/ms-rest-azure-js"
13-
],
10+
external: ["@azure/ms-rest-js", "@azure/ms-rest-azure-js"],
1411
output: {
1512
file: "./dist/arm-recoveryservicesbackup.js",
1613
format: "umd",
@@ -21,17 +18,14 @@ const config = {
2118
"@azure/ms-rest-azure-js": "msRestAzure"
2219
},
2320
banner: `/*
24-
* Copyright (c) Microsoft Corporation. All rights reserved.
25-
* Licensed under the MIT License. See License.txt in the project root for license information.
21+
* Copyright (c) Microsoft Corporation.
22+
* Licensed under the MIT License.
2623
*
2724
* Code generated by Microsoft (R) AutoRest Code Generator.
2825
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
2926
*/`
3027
},
31-
plugins: [
32-
nodeResolve({ mainFields: ['module', 'main'] }),
33-
sourcemaps()
34-
]
28+
plugins: [nodeResolve({ mainFields: ["module", "main"] }), sourcemaps()]
3529
};
3630

3731
export default config;

0 commit comments

Comments
 (0)