Skip to content

Commit

Permalink
CodeGen from PR 14501 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 0fa1d14380ba18b09a24da01fce424612d87d846 into 5fcc6854765009e891052653b304cfe80353430a
  • Loading branch information
SDKAuto committed May 20, 2021
1 parent daddd4b commit dd40f8d
Show file tree
Hide file tree
Showing 27 changed files with 2,172 additions and 342 deletions.
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

0 comments on commit dd40f8d

Please sign in to comment.