Skip to content

Commit 9794b77

Browse files
author
SDKAuto
committed
CodeGen from PR 14011 in Azure/azure-rest-api-specs
Merge bb044e8bbfbaaa6c1da2bc4be68c3b68690fe226 into 88d9023117ea3bfae404a44b755ca7f0bf81b806
1 parent acaccac commit 9794b77

27 files changed

+2172
-342
lines changed

sdk/servicefabric/servicefabric/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) 2019 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/servicefabric/servicefabric/README.md

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,36 @@ npm install @azure/servicefabric
1515

1616
### How to use
1717

18-
#### nodejs - Authentication, client creation and getClusterManifest as an example written in TypeScript.
18+
#### nodejs - client creation and getClusterManifest as an example written in TypeScript.
1919

2020
##### Install @azure/ms-rest-nodeauth
2121

2222
- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.
23-
2423
```bash
2524
npm install @azure/ms-rest-nodeauth@"^3.0.0"
2625
```
2726

2827
##### Sample code
2928

30-
[Service Fabric cluster security scenarios](https://docs.microsoft.com/azure/service-fabric/service-fabric-cluster-security)
31-
29+
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
3230
```typescript
33-
import { ServiceFabricClient } from "@azure/servicefabric";
34-
const baseUri = "<ServiceFabricURL>:<connection-port>";
35-
const client = new ServiceFabricClient({
36-
baseUri
31+
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
32+
const { ServiceFabricClient } = require("@azure/servicefabric");
33+
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
34+
35+
msRestNodeAuth.interactiveLogin().then((creds) => {
36+
const client = new ServiceFabricClient(creds, subscriptionId);
37+
const timeout = 1;
38+
client.getClusterManifest(timeout).then((result) => {
39+
console.log("The result is:");
40+
console.log(result);
41+
});
42+
}).catch((err) => {
43+
console.error(err);
3744
});
38-
client
39-
.getClusterManifest()
40-
.then((result) => {
41-
console.log(result.manifest);
42-
})
43-
.catch(console.error);
4445
```
4546

46-
#### browser - Authentication, client creation and getClusterManifest as an example written in JavaScript.
47+
#### browser - Authentication, client creation and getClusterManifest as an example written in JavaScript.
4748

4849
##### Install @azure/ms-rest-browserauth
4950

@@ -56,29 +57,35 @@ npm install @azure/ms-rest-browserauth
5657
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.
5758

5859
- index.html
59-
6060
```html
6161
<!DOCTYPE html>
6262
<html lang="en">
6363
<head>
6464
<title>@azure/servicefabric sample</title>
6565
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
66+
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
6667
<script src="node_modules/@azure/servicefabric/dist/servicefabric.js"></script>
6768
<script type="text/javascript">
68-
var baseUri = "<ServiceFabricURL>:<connection-port>";
69-
var client = new Azure.Servicefabric.ServiceFabricClient({
70-
baseUri
69+
const subscriptionId = "<Subscription_Id>";
70+
const authManager = new msAuth.AuthManager({
71+
clientId: "<client id for your Azure AD app>",
72+
tenant: "<optional tenant for your organization>"
7173
});
72-
client
73-
.getClusterManifest()
74-
.then((result) => {
74+
authManager.finalizeLogin().then((res) => {
75+
if (!res.isLoggedIn) {
76+
// may cause redirects
77+
authManager.login();
78+
}
79+
const client = new Azure.Servicefabric.ServiceFabricClient(res.creds, subscriptionId);
80+
const timeout = 1;
81+
client.getClusterManifest(timeout).then((result) => {
7582
console.log("The result is:");
7683
console.log(result);
77-
})
78-
.catch((err) => {
84+
}).catch((err) => {
7985
console.log("An error occurred:");
8086
console.error(err);
8187
});
88+
});
8289
</script>
8390
</head>
8491
<body></body>

sdk/servicefabric/servicefabric/rollup.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const config = {
2121
"@azure/ms-rest-azure-js": "msRestAzure"
2222
},
2323
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.
24+
* Copyright (c) Microsoft Corporation.
25+
* Licensed under the MIT License.
2626
*
2727
* Code generated by Microsoft (R) AutoRest Code Generator.
2828
* Changes may cause incorrect behavior and will be lost if the code is regenerated.

0 commit comments

Comments
 (0)