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

[AutoPR @azure/servicefabric] Service fabric Client API 8.0 #4451

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion sdk/servicefabric/servicefabric/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019 Microsoft
Copyright (c) 2021 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
55 changes: 31 additions & 24 deletions sdk/servicefabric/servicefabric/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,36 @@ npm install @azure/servicefabric

### How to use

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

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

- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.

```bash
npm install @azure/ms-rest-nodeauth@"^3.0.0"
```

##### Sample code

[Service Fabric cluster security scenarios](https://docs.microsoft.com/azure/service-fabric/service-fabric-cluster-security)

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
```typescript
import { ServiceFabricClient } from "@azure/servicefabric";
const baseUri = "<ServiceFabricURL>:<connection-port>";
const client = new ServiceFabricClient({
baseUri
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
const { ServiceFabricClient } = require("@azure/servicefabric");
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];

msRestNodeAuth.interactiveLogin().then((creds) => {
const client = new ServiceFabricClient(creds, subscriptionId);
const timeout = 1;
client.getClusterManifest(timeout).then((result) => {
console.log("The result is:");
console.log(result);
});
}).catch((err) => {
console.error(err);
});
client
.getClusterManifest()
.then((result) => {
console.log(result.manifest);
})
.catch(console.error);
```

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

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

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

- index.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>@azure/servicefabric sample</title>
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
<script src="node_modules/@azure/servicefabric/dist/servicefabric.js"></script>
<script type="text/javascript">
var baseUri = "<ServiceFabricURL>:<connection-port>";
var client = new Azure.Servicefabric.ServiceFabricClient({
baseUri
const subscriptionId = "<Subscription_Id>";
const authManager = new msAuth.AuthManager({
clientId: "<client id for your Azure AD app>",
tenant: "<optional tenant for your organization>"
});
client
.getClusterManifest()
.then((result) => {
authManager.finalizeLogin().then((res) => {
if (!res.isLoggedIn) {
// may cause redirects
authManager.login();
}
const client = new Azure.Servicefabric.ServiceFabricClient(res.creds, subscriptionId);
const timeout = 1;
client.getClusterManifest(timeout).then((result) => {
console.log("The result is:");
console.log(result);
})
.catch((err) => {
}).catch((err) => {
console.log("An error occurred:");
console.error(err);
});
});
</script>
</head>
<body></body>
Expand Down
4 changes: 2 additions & 2 deletions sdk/servicefabric/servicefabric/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const config = {
"@azure/ms-rest-azure-js": "msRestAzure"
},
banner: `/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
Expand Down
Loading