Skip to content
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) 2020 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 - Authentication, 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)

```typescript
import { ServiceFabricClient } from "@azure/servicefabric";
const baseUri = "<ServiceFabricURL>:<connection-port>";
const client = new ServiceFabricClient({
baseUri
import * as msRest from "@azure/ms-rest-js";
import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
import { ServiceFabricClient, ServiceFabricModels, ServiceFabricMappers } from "@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
Loading