costmanagement release (#25811)
https://github.com/Azure/sdk-release-request/issues/4088 Recording: https://github.com/Azure/azure-sdk-assets/tree/js/cost-management/arm-costmanagement_5d036a2980
This commit is contained in:
Родитель
51839ddc06
Коммит
7609f53dff
|
@ -62,6 +62,7 @@ specifiers:
|
|||
'@rush-temp/arm-containerservice': file:./projects/arm-containerservice.tgz
|
||||
'@rush-temp/arm-containerservice-1': file:./projects/arm-containerservice-1.tgz
|
||||
'@rush-temp/arm-cosmosdb': file:./projects/arm-cosmosdb.tgz
|
||||
'@rush-temp/arm-costmanagement': file:./projects/arm-costmanagement.tgz
|
||||
'@rush-temp/arm-customerinsights': file:./projects/arm-customerinsights.tgz
|
||||
'@rush-temp/arm-dashboard': file:./projects/arm-dashboard.tgz
|
||||
'@rush-temp/arm-databox': file:./projects/arm-databox.tgz
|
||||
|
@ -402,6 +403,7 @@ dependencies:
|
|||
'@rush-temp/arm-containerservice': file:projects/arm-containerservice.tgz
|
||||
'@rush-temp/arm-containerservice-1': file:projects/arm-containerservice-1.tgz
|
||||
'@rush-temp/arm-cosmosdb': file:projects/arm-cosmosdb.tgz
|
||||
'@rush-temp/arm-costmanagement': file:projects/arm-costmanagement.tgz
|
||||
'@rush-temp/arm-customerinsights': file:projects/arm-customerinsights.tgz
|
||||
'@rush-temp/arm-dashboard': file:projects/arm-dashboard.tgz
|
||||
'@rush-temp/arm-databox': file:projects/arm-databox.tgz
|
||||
|
@ -10808,6 +10810,34 @@ packages:
|
|||
- supports-color
|
||||
dev: false
|
||||
|
||||
file:projects/arm-costmanagement.tgz:
|
||||
resolution: {integrity: sha512-GuzAuQgGacG4YukftbmgRMdW2WnE7CJAQnrZk7KYMVLVys60Xh4Bvr+3RLlyRm4Eyl1qiuMN0GE7e7iwyQ3aLw==, tarball: file:projects/arm-costmanagement.tgz}
|
||||
name: '@rush-temp/arm-costmanagement'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
'@azure/identity': 2.1.0
|
||||
'@microsoft/api-extractor': 7.34.6_@types+node@14.18.43
|
||||
'@rollup/plugin-commonjs': 24.1.0_rollup@2.79.1
|
||||
'@rollup/plugin-json': 6.0.0_rollup@2.79.1
|
||||
'@rollup/plugin-multi-entry': 6.0.0_rollup@2.79.1
|
||||
'@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1
|
||||
'@types/chai': 4.3.5
|
||||
'@types/node': 14.18.43
|
||||
chai: 4.3.7
|
||||
cross-env: 7.0.3
|
||||
dotenv: 16.0.3
|
||||
mkdirp: 2.1.6
|
||||
mocha: 7.2.0
|
||||
rimraf: 3.0.2
|
||||
rollup: 2.79.1
|
||||
rollup-plugin-sourcemaps: 0.6.3_mn2f3gd3jpedkkr23obcmzv5eq
|
||||
tslib: 2.5.0
|
||||
typescript: 5.0.4
|
||||
uglify-js: 3.17.4
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
file:projects/arm-customerinsights.tgz:
|
||||
resolution: {integrity: sha512-1gmbJCRdxihTDmZIbULtE/FXw4+6qiG2xwz8TIz5JaEfeqrsmCI3qfspwz4e6VdkbcNzo/3nrb/wMnlGm2cHdg==, tarball: file:projects/arm-customerinsights.tgz}
|
||||
name: '@rush-temp/arm-customerinsights'
|
||||
|
|
|
@ -12,3 +12,5 @@ https://docs.microsoft.com/javascript/api/@azure/arm-graphservices?view=azure-no
|
|||
https://docs.microsoft.com/javascript/api/@azure/arm-newrelicobservability?view=azure-node-preview
|
||||
https://docs.microsoft.com/javascript/api/@azure/arm-paloaltonetworksngfw?view=azure-node-preview
|
||||
https://docs.microsoft.com/javascript/api/@azure/arm-selfhelp?view=azure-node-preview
|
||||
https://docs.microsoft.com/javascript/api/@azure/arm-costmanagement?view=azure-node-preview
|
||||
https://docs.microsoft.com/javascript/api/@azure/arm-costmanagement
|
||||
|
|
|
@ -1982,6 +1982,11 @@
|
|||
"packageName": "@azure/arm-selfhelp",
|
||||
"projectFolder": "sdk/selfhelp/arm-selfhelp",
|
||||
"versionPolicyName": "management"
|
||||
},
|
||||
{
|
||||
"packageName": "@azure/arm-costmanagement",
|
||||
"projectFolder": "sdk/cost-management/arm-costmanagement",
|
||||
"versionPolicyName": "management"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
# Release History
|
||||
|
||||
## 1.0.0-beta.1 (2023-05-09)
|
||||
|
||||
The package of @azure/arm-costmanagement is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/js-track2-quickstart).
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2023 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
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,109 @@
|
|||
# Azure CostManagement client library for JavaScript
|
||||
|
||||
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure CostManagement client.
|
||||
|
||||
CostManagement management client provides access to CostManagement resources for Azure Enterprise Subscriptions.
|
||||
|
||||
[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cost-management/arm-costmanagement) |
|
||||
[Package (NPM)](https://www.npmjs.com/package/@azure/arm-costmanagement) |
|
||||
[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-costmanagement) |
|
||||
[Samples](https://github.com/Azure-Samples/azure-samples-js-management)
|
||||
|
||||
## Getting started
|
||||
|
||||
### Currently supported environments
|
||||
|
||||
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
|
||||
- Latest versions of Safari, Chrome, Edge and Firefox.
|
||||
|
||||
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- An [Azure subscription][azure_sub].
|
||||
|
||||
### Install the `@azure/arm-costmanagement` package
|
||||
|
||||
Install the Azure CostManagement client library for JavaScript with `npm`:
|
||||
|
||||
```bash
|
||||
npm install @azure/arm-costmanagement
|
||||
```
|
||||
|
||||
### Create and authenticate a `CostManagementClient`
|
||||
|
||||
To create a client object to access the Azure CostManagement API, you will need the `endpoint` of your Azure CostManagement resource and a `credential`. The Azure CostManagement client can use Azure Active Directory credentials to authenticate.
|
||||
You can find the endpoint for your Azure CostManagement resource in the [Azure Portal][azure_portal].
|
||||
|
||||
You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token).
|
||||
|
||||
To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package:
|
||||
|
||||
```bash
|
||||
npm install @azure/identity
|
||||
```
|
||||
|
||||
You will also need to **register a new AAD application and grant access to Azure CostManagement** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions).
|
||||
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`.
|
||||
|
||||
For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal).
|
||||
|
||||
```javascript
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details.
|
||||
|
||||
const subscriptionId = "00000000-0000-0000-0000-000000000000";
|
||||
const client = new CostManagementClient(new DefaultAzureCredential(), subscriptionId);
|
||||
|
||||
// For client-side applications running in the browser, use this code instead:
|
||||
// const credential = new InteractiveBrowserCredential({
|
||||
// tenantId: "<YOUR_TENANT_ID>",
|
||||
// clientId: "<YOUR_CLIENT_ID>"
|
||||
// });
|
||||
// const client = new CostManagementClient(credential, subscriptionId);
|
||||
```
|
||||
|
||||
|
||||
### JavaScript Bundle
|
||||
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).
|
||||
|
||||
## Key concepts
|
||||
|
||||
### CostManagementClient
|
||||
|
||||
`CostManagementClient` is the primary interface for developers using the Azure CostManagement client library. Explore the methods on this client object to understand the different features of the Azure CostManagement service that you can access.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Logging
|
||||
|
||||
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
||||
|
||||
```javascript
|
||||
const { setLogLevel } = require("@azure/logger");
|
||||
setLogLevel("info");
|
||||
```
|
||||
|
||||
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
|
||||
|
||||
## Next steps
|
||||
|
||||
Please take a look at the [samples](https://github.com/Azure-Samples/azure-samples-js-management) directory for detailed examples on how to use this library.
|
||||
|
||||
## Contributing
|
||||
|
||||
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
|
||||
|
||||
## Related projects
|
||||
|
||||
- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)
|
||||
|
||||
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcost-management%2Farm-costmanagement%2FREADME.png)
|
||||
|
||||
[azure_cli]: https://docs.microsoft.com/cli/azure
|
||||
[azure_sub]: https://azure.microsoft.com/free/
|
||||
[azure_sub]: https://azure.microsoft.com/free/
|
||||
[azure_portal]: https://portal.azure.com
|
||||
[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity
|
||||
[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"commit": "d5c8648e01a2a2a743c2649c9522d21f5db952ce",
|
||||
"readme": "specification/cost-management/resource-manager/readme.md",
|
||||
"autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\cost-management\\resource-manager\\readme.md --use=@autorest/typescript@6.0.1 --generate-sample=true",
|
||||
"repository_url": "https://github.com/Azure/azure-rest-api-specs.git",
|
||||
"release_tool": "@azure-tools/js-sdk-release-tools@2.6.2",
|
||||
"use": "@autorest/typescript@6.0.1"
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "./dist-esm/src/index.d.ts",
|
||||
"docModel": {
|
||||
"enabled": true
|
||||
},
|
||||
"apiReport": {
|
||||
"enabled": true,
|
||||
"reportFolder": "./review"
|
||||
},
|
||||
"dtsRollup": {
|
||||
"enabled": true,
|
||||
"untrimmedFilePath": "",
|
||||
"publicTrimmedFilePath": "./types/arm-costmanagement.d.ts"
|
||||
},
|
||||
"messages": {
|
||||
"tsdocMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "none"
|
||||
}
|
||||
},
|
||||
"extractorMessageReporting": {
|
||||
"ae-missing-release-tag": {
|
||||
"logLevel": "none"
|
||||
},
|
||||
"ae-unresolved-link": {
|
||||
"logLevel": "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"AssetsRepo": "Azure/azure-sdk-assets",
|
||||
"AssetsRepoPrefixPath": "js",
|
||||
"TagPrefix": "js/cost-management/arm-costmanagement",
|
||||
"Tag": "js/cost-management/arm-costmanagement_5d036a2980"
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
{
|
||||
"name": "@azure/arm-costmanagement",
|
||||
"sdk-type": "mgmt",
|
||||
"author": "Microsoft Corporation",
|
||||
"description": "A generated SDK for CostManagementClient.",
|
||||
"version": "1.0.0-beta.1",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@azure/core-lro": "^2.5.0",
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"@azure/core-paging": "^1.2.0",
|
||||
"@azure/core-client": "^1.7.0",
|
||||
"@azure/core-auth": "^1.3.0",
|
||||
"@azure/core-rest-pipeline": "^1.8.0",
|
||||
"tslib": "^2.2.0"
|
||||
},
|
||||
"keywords": [
|
||||
"node",
|
||||
"azure",
|
||||
"typescript",
|
||||
"browser",
|
||||
"isomorphic"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist-esm/src/index.js",
|
||||
"types": "./types/arm-costmanagement.d.ts",
|
||||
"devDependencies": {
|
||||
"@microsoft/api-extractor": "^7.31.1",
|
||||
"@rollup/plugin-commonjs": "^24.0.0",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-multi-entry": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^13.1.3",
|
||||
"mkdirp": "^2.1.2",
|
||||
"rollup": "^2.66.1",
|
||||
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||
"typescript": "~5.0.0",
|
||||
"uglify-js": "^3.4.9",
|
||||
"rimraf": "^3.0.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"@azure/identity": "^2.0.1",
|
||||
"@azure-tools/test-recorder": "^3.0.0",
|
||||
"@azure-tools/test-credential": "^1.0.0",
|
||||
"mocha": "^7.1.1",
|
||||
"@types/chai": "^4.2.8",
|
||||
"chai": "^4.2.0",
|
||||
"cross-env": "^7.0.2",
|
||||
"@types/node": "^14.0.0",
|
||||
"@azure/dev-tool": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Azure/azure-sdk-for-js.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*.js",
|
||||
"dist/**/*.js.map",
|
||||
"dist/**/*.d.ts",
|
||||
"dist/**/*.d.ts.map",
|
||||
"dist-esm/**/*.js",
|
||||
"dist-esm/**/*.js.map",
|
||||
"dist-esm/**/*.d.ts",
|
||||
"dist-esm/**/*.d.ts.map",
|
||||
"src/**/*.ts",
|
||||
"README.md",
|
||||
"LICENSE",
|
||||
"rollup.config.js",
|
||||
"tsconfig.json",
|
||||
"review/*",
|
||||
"CHANGELOG.md",
|
||||
"types/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "npm run clean && tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api",
|
||||
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js",
|
||||
"prepack": "npm run build",
|
||||
"pack": "npm pack 2>&1",
|
||||
"extract-api": "api-extractor run --local",
|
||||
"lint": "echo skipped",
|
||||
"audit": "echo skipped",
|
||||
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
|
||||
"build:node": "echo skipped",
|
||||
"build:browser": "echo skipped",
|
||||
"build:test": "echo skipped",
|
||||
"build:samples": "echo skipped.",
|
||||
"check-format": "echo skipped",
|
||||
"execute:samples": "echo skipped",
|
||||
"format": "echo skipped",
|
||||
"test": "npm run integration-test",
|
||||
"test:node": "echo skipped",
|
||||
"test:browser": "echo skipped",
|
||||
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
||||
"unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node",
|
||||
"unit-test:browser": "echo skipped",
|
||||
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
||||
"integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'",
|
||||
"integration-test:browser": "echo skipped"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"//metadata": {
|
||||
"constantPaths": [
|
||||
{
|
||||
"path": "src/costManagementClient.ts",
|
||||
"prefix": "packageDetails"
|
||||
}
|
||||
]
|
||||
},
|
||||
"autoPublish": true,
|
||||
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cost-management/arm-costmanagement",
|
||||
"//sampleConfiguration": {
|
||||
"productName": "",
|
||||
"productSlugs": [
|
||||
"azure"
|
||||
],
|
||||
"disableDocsMs": true,
|
||||
"apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-costmanagement?view=azure-node-preview"
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import nodeResolve from "@rollup/plugin-node-resolve";
|
||||
import cjs from "@rollup/plugin-commonjs";
|
||||
import sourcemaps from "rollup-plugin-sourcemaps";
|
||||
import multiEntry from "@rollup/plugin-multi-entry";
|
||||
import json from "@rollup/plugin-json";
|
||||
|
||||
import nodeBuiltins from "builtin-modules";
|
||||
|
||||
// #region Warning Handler
|
||||
|
||||
/**
|
||||
* A function that can determine whether a rollup warning should be ignored. If
|
||||
* the function returns `true`, then the warning will not be displayed.
|
||||
*/
|
||||
|
||||
function ignoreNiseSinonEval(warning) {
|
||||
return (
|
||||
warning.code === "EVAL" &&
|
||||
warning.id &&
|
||||
(warning.id.includes("node_modules/nise") ||
|
||||
warning.id.includes("node_modules/sinon")) === true
|
||||
);
|
||||
}
|
||||
|
||||
function ignoreChaiCircularDependency(warning) {
|
||||
return (
|
||||
warning.code === "CIRCULAR_DEPENDENCY" &&
|
||||
warning.importer && warning.importer.includes("node_modules/chai") === true
|
||||
);
|
||||
}
|
||||
|
||||
const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval];
|
||||
|
||||
/**
|
||||
* Construct a warning handler for the shared rollup configuration
|
||||
* that ignores certain warnings that are not relevant to testing.
|
||||
*/
|
||||
function makeOnWarnForTesting() {
|
||||
return (warning, warn) => {
|
||||
// If every inhibitor returns false (i.e. no inhibitors), then show the warning
|
||||
if (warningInhibitors.every((inhib) => !inhib(warning))) {
|
||||
warn(warning);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
function makeBrowserTestConfig() {
|
||||
const config = {
|
||||
input: {
|
||||
include: ["dist-esm/test/**/*.spec.js"],
|
||||
exclude: ["dist-esm/test/**/node/**"]
|
||||
},
|
||||
output: {
|
||||
file: `dist-test/index.browser.js`,
|
||||
format: "umd",
|
||||
sourcemap: true
|
||||
},
|
||||
preserveSymlinks: false,
|
||||
plugins: [
|
||||
multiEntry({ exports: false }),
|
||||
nodeResolve({
|
||||
mainFields: ["module", "browser"]
|
||||
}),
|
||||
cjs(),
|
||||
json(),
|
||||
sourcemaps()
|
||||
//viz({ filename: "dist-test/browser-stats.html", sourcemap: true })
|
||||
],
|
||||
onwarn: makeOnWarnForTesting(),
|
||||
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0,
|
||||
// rollup started respecting the "sideEffects" field in package.json. Since
|
||||
// our package.json sets "sideEffects=false", this also applies to test
|
||||
// code, which causes all tests to be removed by tree-shaking.
|
||||
treeshake: false
|
||||
};
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
const defaultConfigurationOptions = {
|
||||
disableBrowserBundle: false
|
||||
};
|
||||
|
||||
export function makeConfig(pkg, options) {
|
||||
options = {
|
||||
...defaultConfigurationOptions,
|
||||
...(options || {})
|
||||
};
|
||||
|
||||
const baseConfig = {
|
||||
// Use the package's module field if it has one
|
||||
input: pkg["module"] || "dist-esm/src/index.js",
|
||||
external: [
|
||||
...nodeBuiltins,
|
||||
...Object.keys(pkg.dependencies),
|
||||
...Object.keys(pkg.devDependencies)
|
||||
],
|
||||
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
|
||||
preserveSymlinks: false,
|
||||
plugins: [sourcemaps(), nodeResolve()]
|
||||
};
|
||||
|
||||
const config = [baseConfig];
|
||||
|
||||
if (!options.disableBrowserBundle) {
|
||||
config.push(makeBrowserTestConfig());
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
export default makeConfig(require("./package.json"));
|
|
@ -0,0 +1,4 @@
|
|||
# App registration secret for AAD authentication
|
||||
AZURE_CLIENT_SECRET=
|
||||
AZURE_CLIENT_ID=
|
||||
AZURE_TENANT_ID=
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
DismissAlertPayload,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Dismisses the specified alert
|
||||
*
|
||||
* @summary Dismisses the specified alert
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DismissResourceGroupAlerts.json
|
||||
*/
|
||||
async function patchResourceGroupAlerts() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const alertId = "22222222-2222-2222-2222-222222222222";
|
||||
const parameters: DismissAlertPayload = { status: "Dismissed" };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.dismiss(scope, alertId, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Dismisses the specified alert
|
||||
*
|
||||
* @summary Dismisses the specified alert
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DismissSubscriptionAlerts.json
|
||||
*/
|
||||
async function patchSubscriptionAlerts() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const alertId = "22222222-2222-2222-2222-222222222222";
|
||||
const parameters: DismissAlertPayload = { status: "Dismissed" };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.dismiss(scope, alertId, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
patchResourceGroupAlerts();
|
||||
patchSubscriptionAlerts();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets the alert for the scope by alert ID.
|
||||
*
|
||||
* @summary Gets the alert for the scope by alert ID.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SingleResourceGroupAlert.json
|
||||
*/
|
||||
async function singleResourceGroupAlerts() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const alertId = "22222222-2222-2222-2222-222222222222";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.get(scope, alertId);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets the alert for the scope by alert ID.
|
||||
*
|
||||
* @summary Gets the alert for the scope by alert ID.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SingleSubscriptionAlert.json
|
||||
*/
|
||||
async function singleSubscriptionAlerts() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const alertId = "22222222-2222-2222-2222-222222222222";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.get(scope, alertId);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
singleResourceGroupAlerts();
|
||||
singleSubscriptionAlerts();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the Alerts for external cloud provider type defined.
|
||||
*
|
||||
* @summary Lists the Alerts for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountAlerts.json
|
||||
*/
|
||||
async function externalBillingAccountAlerts() {
|
||||
const externalCloudProviderType = "externalBillingAccounts";
|
||||
const externalCloudProviderId = "100";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.listExternal(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the Alerts for external cloud provider type defined.
|
||||
*
|
||||
* @summary Lists the Alerts for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionAlerts.json
|
||||
*/
|
||||
async function externalSubscriptionAlerts() {
|
||||
const externalCloudProviderType = "externalSubscriptions";
|
||||
const externalCloudProviderId = "100";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.listExternal(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
externalBillingAccountAlerts();
|
||||
externalSubscriptionAlerts();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountAlerts.json
|
||||
*/
|
||||
async function billingAccountAlerts() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingProfileAlerts.json
|
||||
*/
|
||||
async function billingProfileAlerts() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentAlerts.json
|
||||
*/
|
||||
async function departmentAlerts() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountAlerts.json
|
||||
*/
|
||||
async function enrollmentAccountAlerts() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/InvoiceSectionAlerts.json
|
||||
*/
|
||||
async function invoiceSectionAlerts() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupAlerts.json
|
||||
*/
|
||||
async function resourceGroupAlerts() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionAlerts.json
|
||||
*/
|
||||
async function subscriptionAlerts() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
billingAccountAlerts();
|
||||
billingProfileAlerts();
|
||||
departmentAlerts();
|
||||
enrollmentAccountAlerts();
|
||||
invoiceSectionAlerts();
|
||||
resourceGroupAlerts();
|
||||
subscriptionAlerts();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
BenefitRecommendationsListOptionalParams,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to List of recommendations for purchasing savings plan.
|
||||
*
|
||||
* @summary List of recommendations for purchasing savings plan.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitRecommendationsByBillingAccount.json
|
||||
*/
|
||||
async function benefitRecommendationsBillingAccountList() {
|
||||
const filter =
|
||||
"properties/lookBackPeriod eq 'Last7Days' AND properties/term eq 'P1Y'";
|
||||
const expand = "properties/usage,properties/allRecommendationDetails";
|
||||
const billingScope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const options: BenefitRecommendationsListOptionalParams = { filter, expand };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.benefitRecommendations.list(
|
||||
billingScope,
|
||||
options
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
benefitRecommendationsBillingAccountList();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
BenefitUtilizationSummariesListByBillingAccountIdOptionalParams,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists savings plan utilization summaries for the enterprise agreement scope. Supported at grain values: 'Daily' and 'Monthly'.
|
||||
*
|
||||
* @summary Lists savings plan utilization summaries for the enterprise agreement scope. Supported at grain values: 'Daily' and 'Monthly'.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-BillingAccount.json
|
||||
*/
|
||||
async function savingsPlanUtilizationSummariesBillingAccount() {
|
||||
const billingAccountId = "12345";
|
||||
const filter =
|
||||
"properties/usageDate ge 2022-10-15 and properties/usageDate le 2022-10-18";
|
||||
const options: BenefitUtilizationSummariesListByBillingAccountIdOptionalParams = {
|
||||
filter
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.benefitUtilizationSummaries.listByBillingAccountId(
|
||||
billingAccountId,
|
||||
options
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
savingsPlanUtilizationSummariesBillingAccount();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
BenefitUtilizationSummariesListByBillingProfileIdOptionalParams,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists savings plan utilization summaries for billing profile. Supported at grain values: 'Daily' and 'Monthly'.
|
||||
*
|
||||
* @summary Lists savings plan utilization summaries for billing profile. Supported at grain values: 'Daily' and 'Monthly'.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-BillingProfile.json
|
||||
*/
|
||||
async function savingsPlanUtilizationSummariesBillingProfile() {
|
||||
const billingAccountId =
|
||||
"c0a00000-0e04-5ee3-000e-f0c6e00000ec:c0a00000-0e04-5ee3-000e-f0c6e00000ec";
|
||||
const billingProfileId = "200e5e90-000e-4960-8dcd-8d00a02db000";
|
||||
const filter =
|
||||
"properties/usageDate ge 2022-10-15 and properties/usageDate le 2022-10-18";
|
||||
const options: BenefitUtilizationSummariesListByBillingProfileIdOptionalParams = {
|
||||
filter
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.benefitUtilizationSummaries.listByBillingProfileId(
|
||||
billingAccountId,
|
||||
billingProfileId,
|
||||
options
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
savingsPlanUtilizationSummariesBillingProfile();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the savings plan utilization summaries for daily or monthly grain.
|
||||
*
|
||||
* @summary Lists the savings plan utilization summaries for daily or monthly grain.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanId-Monthly.json
|
||||
*/
|
||||
async function savingsPlanUtilizationSummariesMonthlyWithSavingsPlanId() {
|
||||
const savingsPlanOrderId = "66cccc66-6ccc-6c66-666c-66cc6c6c66c6";
|
||||
const savingsPlanId = "222d22dd-d2d2-2dd2-222d-2dd2222ddddd";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.benefitUtilizationSummaries.listBySavingsPlanId(
|
||||
savingsPlanOrderId,
|
||||
savingsPlanId
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
savingsPlanUtilizationSummariesMonthlyWithSavingsPlanId();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the savings plan utilization summaries for daily or monthly grain.
|
||||
*
|
||||
* @summary Lists the savings plan utilization summaries for daily or monthly grain.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanOrderId-Daily.json
|
||||
*/
|
||||
async function savingsPlanUtilizationSummariesDaily() {
|
||||
const savingsPlanOrderId = "66cccc66-6ccc-6c66-666c-66cc6c6c66c6";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.benefitUtilizationSummaries.listBySavingsPlanOrder(
|
||||
savingsPlanOrderId
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
savingsPlanUtilizationSummariesDaily();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the external cloud provider type.
|
||||
*
|
||||
* @summary Lists the dimensions by the external cloud provider type.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountsDimensions.json
|
||||
*/
|
||||
async function externalBillingAccountDimensionList() {
|
||||
const externalCloudProviderType = "externalBillingAccounts";
|
||||
const externalCloudProviderId = "100";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.listByExternalCloudProviderType(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the external cloud provider type.
|
||||
*
|
||||
* @summary Lists the dimensions by the external cloud provider type.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionsDimensions.json
|
||||
*/
|
||||
async function externalSubscriptionDimensionList() {
|
||||
const externalCloudProviderType = "externalSubscriptions";
|
||||
const externalCloudProviderId = "100";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.listByExternalCloudProviderType(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
externalBillingAccountDimensionList();
|
||||
externalSubscriptionDimensionList();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,569 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
DimensionsListOptionalParams,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsList.json
|
||||
*/
|
||||
async function billingAccountDimensionsListLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountDimensionsList.json
|
||||
*/
|
||||
async function billingAccountDimensionsListMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function billingAccountDimensionsListExpandAndTopLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function billingAccountDimensionsListExpandAndTopMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsListWithFilter.json
|
||||
*/
|
||||
async function billingAccountDimensionsListWithFilterLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountDimensionsListWithFilter.json
|
||||
*/
|
||||
async function billingAccountDimensionsListWithFilterMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileDimensionsList.json
|
||||
*/
|
||||
async function billingProfileDimensionsListMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function billingProfileDimensionsListExpandAndTopMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileDimensionsListWithFilter.json
|
||||
*/
|
||||
async function billingProfileDimensionsListWithFilterMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerDimensionsList.json
|
||||
*/
|
||||
async function customerDimensionsListMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function customerDimensionsListExpandAndTopMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerDimensionsListWithFilter.json
|
||||
*/
|
||||
async function customerDimensionsListWithFilterMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentDimensionsList.json
|
||||
*/
|
||||
async function departmentDimensionsListLegacy() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/departments/123";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function departmentDimensionsListExpandAndTopLegacy() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/departments/123";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentDimensionsListWithFilter.json
|
||||
*/
|
||||
async function departmentDimensionsListWithFilterLegacy() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/departments/123";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountDimensionsList.json
|
||||
*/
|
||||
async function enrollmentAccountDimensionsListLegacy() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function enrollmentAccountDimensionsListExpandAndTopLegacy() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountDimensionsListWithFilter.json
|
||||
*/
|
||||
async function enrollmentAccountDimensionsListWithFilterLegacy() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionDimensionsList.json
|
||||
*/
|
||||
async function invoiceSectionDimensionsListMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function invoiceSectionDimensionsListExpandAndTopMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionDimensionsListWithFilter.json
|
||||
*/
|
||||
async function invoiceSectionDimensionsListWithFilterMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupDimensionsList.json
|
||||
*/
|
||||
async function managementGroupDimensionsListLegacy() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/MyMgId";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function managementGroupDimensionsListExpandAndTopLegacy() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/MyMgId";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupDimensionsListWithFilter.json
|
||||
*/
|
||||
async function managementGroupDimensionsListWithFilterLegacy() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/MyMgId";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupDimensionsList.json
|
||||
*/
|
||||
async function resourceGroupDimensionsListLegacy() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/system.orlando";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionDimensionsList.json
|
||||
*/
|
||||
async function subscriptionDimensionsListLegacy() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options: DimensionsListOptionalParams = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
billingAccountDimensionsListLegacy();
|
||||
billingAccountDimensionsListMca();
|
||||
billingAccountDimensionsListExpandAndTopLegacy();
|
||||
billingAccountDimensionsListExpandAndTopMca();
|
||||
billingAccountDimensionsListWithFilterLegacy();
|
||||
billingAccountDimensionsListWithFilterMca();
|
||||
billingProfileDimensionsListMca();
|
||||
billingProfileDimensionsListExpandAndTopMca();
|
||||
billingProfileDimensionsListWithFilterMca();
|
||||
customerDimensionsListMca();
|
||||
customerDimensionsListExpandAndTopMca();
|
||||
customerDimensionsListWithFilterMca();
|
||||
departmentDimensionsListLegacy();
|
||||
departmentDimensionsListExpandAndTopLegacy();
|
||||
departmentDimensionsListWithFilterLegacy();
|
||||
enrollmentAccountDimensionsListLegacy();
|
||||
enrollmentAccountDimensionsListExpandAndTopLegacy();
|
||||
enrollmentAccountDimensionsListWithFilterLegacy();
|
||||
invoiceSectionDimensionsListMca();
|
||||
invoiceSectionDimensionsListExpandAndTopMca();
|
||||
invoiceSectionDimensionsListWithFilterMca();
|
||||
managementGroupDimensionsListLegacy();
|
||||
managementGroupDimensionsListExpandAndTopLegacy();
|
||||
managementGroupDimensionsListWithFilterLegacy();
|
||||
resourceGroupDimensionsListLegacy();
|
||||
subscriptionDimensionsListLegacy();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,353 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { Export, CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByBillingAccount.json
|
||||
*/
|
||||
async function exportCreateOrUpdateByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const exportName = "TestExport";
|
||||
const parameters: Export = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: [
|
||||
"Date",
|
||||
"MeterId",
|
||||
"ResourceId",
|
||||
"ResourceLocation",
|
||||
"Quantity"
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc"
|
||||
}
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z")
|
||||
},
|
||||
status: "Active"
|
||||
}
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(
|
||||
scope,
|
||||
exportName,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByDepartment.json
|
||||
*/
|
||||
async function exportCreateOrUpdateByDepartment() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12/departments/1234";
|
||||
const exportName = "TestExport";
|
||||
const parameters: Export = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: [
|
||||
"Date",
|
||||
"MeterId",
|
||||
"ResourceId",
|
||||
"ResourceLocation",
|
||||
"Quantity"
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc"
|
||||
}
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z")
|
||||
},
|
||||
status: "Active"
|
||||
}
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(
|
||||
scope,
|
||||
exportName,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportCreateOrUpdateByEnrollmentAccount() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const exportName = "TestExport";
|
||||
const parameters: Export = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: [
|
||||
"Date",
|
||||
"MeterId",
|
||||
"ResourceId",
|
||||
"ResourceLocation",
|
||||
"Quantity"
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc"
|
||||
}
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z")
|
||||
},
|
||||
status: "Active"
|
||||
}
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(
|
||||
scope,
|
||||
exportName,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByManagementGroup.json
|
||||
*/
|
||||
async function exportCreateOrUpdateByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const exportName = "TestExport";
|
||||
const parameters: Export = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: [
|
||||
"Date",
|
||||
"MeterId",
|
||||
"ResourceId",
|
||||
"ResourceLocation",
|
||||
"Quantity"
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc"
|
||||
}
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z")
|
||||
},
|
||||
status: "Active"
|
||||
}
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(
|
||||
scope,
|
||||
exportName,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByResourceGroup.json
|
||||
*/
|
||||
async function exportCreateOrUpdateByResourceGroup() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const exportName = "TestExport";
|
||||
const parameters: Export = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: [
|
||||
"Date",
|
||||
"MeterId",
|
||||
"ResourceId",
|
||||
"ResourceLocation",
|
||||
"Quantity"
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc"
|
||||
}
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z")
|
||||
},
|
||||
status: "Active"
|
||||
}
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(
|
||||
scope,
|
||||
exportName,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateBySubscription.json
|
||||
*/
|
||||
async function exportCreateOrUpdateBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const exportName = "TestExport";
|
||||
const parameters: Export = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: [
|
||||
"Date",
|
||||
"MeterId",
|
||||
"ResourceId",
|
||||
"ResourceLocation",
|
||||
"Quantity"
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc"
|
||||
}
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z")
|
||||
},
|
||||
status: "Active"
|
||||
}
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(
|
||||
scope,
|
||||
exportName,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportCreateOrUpdateByBillingAccount();
|
||||
exportCreateOrUpdateByDepartment();
|
||||
exportCreateOrUpdateByEnrollmentAccount();
|
||||
exportCreateOrUpdateByManagementGroup();
|
||||
exportCreateOrUpdateByResourceGroup();
|
||||
exportCreateOrUpdateBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByBillingAccount.json
|
||||
*/
|
||||
async function exportDeleteByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByDepartment.json
|
||||
*/
|
||||
async function exportDeleteByDepartment() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12/departments/1234";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportDeleteByEnrollmentAccount() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByManagementGroup.json
|
||||
*/
|
||||
async function exportDeleteByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByResourceGroup.json
|
||||
*/
|
||||
async function exportDeleteByResourceGroup() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteBySubscription.json
|
||||
*/
|
||||
async function exportDeleteBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportDeleteByBillingAccount();
|
||||
exportDeleteByDepartment();
|
||||
exportDeleteByEnrollmentAccount();
|
||||
exportDeleteByManagementGroup();
|
||||
exportDeleteByResourceGroup();
|
||||
exportDeleteBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByBillingAccount.json
|
||||
*/
|
||||
async function exportRunByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByDepartment.json
|
||||
*/
|
||||
async function exportRunByDepartment() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12/departments/1234";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportRunByEnrollmentAccount() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByManagementGroup.json
|
||||
*/
|
||||
async function exportRunByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByResourceGroup.json
|
||||
*/
|
||||
async function exportRunByResourceGroup() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunBySubscription.json
|
||||
*/
|
||||
async function exportRunBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportRunByBillingAccount();
|
||||
exportRunByDepartment();
|
||||
exportRunByEnrollmentAccount();
|
||||
exportRunByManagementGroup();
|
||||
exportRunByResourceGroup();
|
||||
exportRunBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByBillingAccount.json
|
||||
*/
|
||||
async function exportRunHistoryGetByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByDepartment.json
|
||||
*/
|
||||
async function exportRunHistoryGetByDepartment() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12/departments/1234";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportRunHistoryGetByEnrollmentAccount() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByManagementGroup.json
|
||||
*/
|
||||
async function exportRunHistoryGetByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByResourceGroup.json
|
||||
*/
|
||||
async function exportRunHistoryGetByResourceGroup() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetBySubscription.json
|
||||
*/
|
||||
async function exportRunHistoryGetBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportRunHistoryGetByBillingAccount();
|
||||
exportRunHistoryGetByDepartment();
|
||||
exportRunHistoryGetByEnrollmentAccount();
|
||||
exportRunHistoryGetByManagementGroup();
|
||||
exportRunHistoryGetByResourceGroup();
|
||||
exportRunHistoryGetBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByBillingAccount.json
|
||||
*/
|
||||
async function exportGetByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByDepartment.json
|
||||
*/
|
||||
async function exportGetByDepartment() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12/departments/1234";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportGetByEnrollmentAccount() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByManagementGroup.json
|
||||
*/
|
||||
async function exportGetByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByResourceGroup.json
|
||||
*/
|
||||
async function exportGetByResourceGroup() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetBySubscription.json
|
||||
*/
|
||||
async function exportGetBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportGetByBillingAccount();
|
||||
exportGetByDepartment();
|
||||
exportGetByEnrollmentAccount();
|
||||
exportGetByManagementGroup();
|
||||
exportGetByResourceGroup();
|
||||
exportGetBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByBillingAccount.json
|
||||
*/
|
||||
async function exportsGetByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByDepartment.json
|
||||
*/
|
||||
async function exportsGetByDepartment() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12/departments/123";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportsGetByEnrollmentAccount() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByManagementGroup.json
|
||||
*/
|
||||
async function exportsGetByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByResourceGroup.json
|
||||
*/
|
||||
async function exportsGetByResourceGroup() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetBySubscription.json
|
||||
*/
|
||||
async function exportsGetBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportsGetByBillingAccount();
|
||||
exportsGetByDepartment();
|
||||
exportsGetByEnrollmentAccount();
|
||||
exportsGetByManagementGroup();
|
||||
exportsGetByResourceGroup();
|
||||
exportsGetBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
ForecastDefinition,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for external cloud provider type defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountForecast.json
|
||||
*/
|
||||
async function externalBillingAccountForecast() {
|
||||
const externalCloudProviderType = "externalBillingAccounts";
|
||||
const externalCloudProviderId = "100";
|
||||
const parameters: ForecastDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00")
|
||||
},
|
||||
timeframe: "Custom"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.externalCloudProviderUsage(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for external cloud provider type defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionForecast.json
|
||||
*/
|
||||
async function externalSubscriptionForecast() {
|
||||
const externalCloudProviderType = "externalSubscriptions";
|
||||
const externalCloudProviderId = "100";
|
||||
const parameters: ForecastDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00")
|
||||
},
|
||||
timeframe: "Custom"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.externalCloudProviderUsage(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
externalBillingAccountForecast();
|
||||
externalSubscriptionForecast();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,434 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
ForecastDefinition,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountForecast.json
|
||||
*/
|
||||
async function billingAccountForecast() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const parameters: ForecastDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00")
|
||||
},
|
||||
timeframe: "Custom"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingProfileForecast.json
|
||||
*/
|
||||
async function billingProfileForecast() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters: ForecastDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00")
|
||||
},
|
||||
timeframe: "Custom"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentForecast.json
|
||||
*/
|
||||
async function departmentForecast() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123";
|
||||
const parameters: ForecastDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00")
|
||||
},
|
||||
timeframe: "Custom"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountForecast.json
|
||||
*/
|
||||
async function enrollmentAccountForecast() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456";
|
||||
const parameters: ForecastDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00")
|
||||
},
|
||||
timeframe: "Custom"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/InvoiceSectionForecast.json
|
||||
*/
|
||||
async function invoiceSectionForecast() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const parameters: ForecastDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00")
|
||||
},
|
||||
timeframe: "Custom"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupForecast.json
|
||||
*/
|
||||
async function resourceGroupForecast() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const parameters: ForecastDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00")
|
||||
},
|
||||
timeframe: "Custom"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionForecast.json
|
||||
*/
|
||||
async function subscriptionForecast() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const parameters: ForecastDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00")
|
||||
},
|
||||
timeframe: "Custom"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
billingAccountForecast();
|
||||
billingProfileForecast();
|
||||
departmentForecast();
|
||||
enrollmentAccountForecast();
|
||||
invoiceSectionForecast();
|
||||
resourceGroupForecast();
|
||||
subscriptionForecast();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
GenerateCostDetailsReportRequestDefinition,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod.json
|
||||
*/
|
||||
async function generateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345";
|
||||
const parameters: GenerateCostDetailsReportRequestDefinition = {
|
||||
billingPeriod: "202205",
|
||||
metric: "ActualCost"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingProfileAndInvoiceId.json
|
||||
*/
|
||||
async function generateCostDetailsReportByBillingProfileAndInvoiceId() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters: GenerateCostDetailsReportRequestDefinition = {
|
||||
invoiceId: "M1234567",
|
||||
metric: "ActualCost"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId.json
|
||||
*/
|
||||
async function generateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579";
|
||||
const parameters: GenerateCostDetailsReportRequestDefinition = {
|
||||
invoiceId: "M1234567",
|
||||
metric: "ActualCost"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByCustomerAndTimePeriod.json
|
||||
*/
|
||||
async function generateCostDetailsReportByCustomerAndTimePeriod() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579";
|
||||
const parameters: GenerateCostDetailsReportRequestDefinition = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" }
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByDepartmentsAndTimePeriod.json
|
||||
*/
|
||||
async function generateCostDetailsReportByDepartmentsAndTimePeriod() {
|
||||
const scope = "providers/Microsoft.Billing/departments/12345";
|
||||
const parameters: GenerateCostDetailsReportRequestDefinition = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" }
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByEnrollmentAccountsAndTimePeriod.json
|
||||
*/
|
||||
async function generateCostDetailsReportByEnrollmentAccountsAndTimePeriod() {
|
||||
const scope = "providers/Microsoft.Billing/enrollmentAccounts/1234";
|
||||
const parameters: GenerateCostDetailsReportRequestDefinition = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" }
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportBySubscriptionAndTimePeriod.json
|
||||
*/
|
||||
async function generateCostDetailsReportBySubscriptionAndTimePeriod() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const parameters: GenerateCostDetailsReportRequestDefinition = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" }
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
generateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod();
|
||||
generateCostDetailsReportByBillingProfileAndInvoiceId();
|
||||
generateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId();
|
||||
generateCostDetailsReportByCustomerAndTimePeriod();
|
||||
generateCostDetailsReportByDepartmentsAndTimePeriod();
|
||||
generateCostDetailsReportByEnrollmentAccountsAndTimePeriod();
|
||||
generateCostDetailsReportBySubscriptionAndTimePeriod();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Get the result of the specified operation. This link is provided in the CostDetails creation request response Location header.
|
||||
*
|
||||
* @summary Get the result of the specified operation. This link is provided in the CostDetails creation request response Location header.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/CostDetailsOperationResultsBySubscriptionScope.json
|
||||
*/
|
||||
async function getDetailsOfTheOperationResult() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const operationId = "00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginGetOperationResultsAndWait(
|
||||
scope,
|
||||
operationId
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
getDetailsOfTheOperationResult();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
GenerateDetailedCostReportDefinition,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
*
|
||||
* @summary Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingAccountLegacyAndBillingPeriod.json
|
||||
*/
|
||||
async function generateDetailedCostReportByBillingAccountLegacyAndBillingPeriod() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345";
|
||||
const parameters: GenerateDetailedCostReportDefinition = {
|
||||
billingPeriod: "202008",
|
||||
metric: "ActualCost"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
*
|
||||
* @summary Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingProfileAndInvoiceId.json
|
||||
*/
|
||||
async function generateDetailedCostReportByBillingProfileAndInvoiceId() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters: GenerateDetailedCostReportDefinition = {
|
||||
invoiceId: "M1234567",
|
||||
metric: "ActualCost"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
*
|
||||
* @summary Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId.json
|
||||
*/
|
||||
async function generateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters: GenerateDetailedCostReportDefinition = {
|
||||
customerId: "456789",
|
||||
invoiceId: "M1234567",
|
||||
metric: "ActualCost"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
*
|
||||
* @summary Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByCustomerAndTimePeriod.json
|
||||
*/
|
||||
async function generateDetailedCostReportByCustomerAndTimePeriod() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579";
|
||||
const parameters: GenerateDetailedCostReportDefinition = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" }
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
*
|
||||
* @summary Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportBySubscriptionAndTimePeriod.json
|
||||
*/
|
||||
async function generateDetailedCostReportBySubscriptionAndTimePeriod() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const parameters: GenerateDetailedCostReportDefinition = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" }
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
generateDetailedCostReportByBillingAccountLegacyAndBillingPeriod();
|
||||
generateDetailedCostReportByBillingProfileAndInvoiceId();
|
||||
generateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId();
|
||||
generateDetailedCostReportByCustomerAndTimePeriod();
|
||||
generateDetailedCostReportBySubscriptionAndTimePeriod();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets the result of the specified operation. The link with this operationId is provided as a response header of the initial request.
|
||||
*
|
||||
* @summary Gets the result of the specified operation. The link with this operationId is provided as a response header of the initial request.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportOperationResultsBySubscriptionScope.json
|
||||
*/
|
||||
async function getDetailsOfTheOperationResult() {
|
||||
const operationId = "00000000-0000-0000-0000-000000000000";
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReportOperationResults.beginGetAndWait(
|
||||
operationId,
|
||||
scope
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
getDetailsOfTheOperationResult();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Get the status of the specified operation. This link is provided in the GenerateDetailedCostReport creation request response header.
|
||||
*
|
||||
* @summary Get the status of the specified operation. This link is provided in the GenerateDetailedCostReport creation request response header.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportOperationStatusBySubscriptionScope.json
|
||||
*/
|
||||
async function getDetailsOfTheOperationStatus() {
|
||||
const operationId = "00000000-0000-0000-0000-000000000000";
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReportOperationStatus.get(
|
||||
operationId,
|
||||
scope
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
getDetailsOfTheOperationStatus();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the reservations details report for provided date range asynchronously based on enrollment id. The Reservation usage details can be viewed only by certain enterprise roles. For more details on the roles see, https://docs.microsoft.com/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role
|
||||
*
|
||||
* @summary Generates the reservations details report for provided date range asynchronously based on enrollment id. The Reservation usage details can be viewed only by certain enterprise roles. For more details on the roles see, https://docs.microsoft.com/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateReservationDetailsReportByBillingAccount.json
|
||||
*/
|
||||
async function reservationDetails() {
|
||||
const billingAccountId = "9845612";
|
||||
const startDate = "2020-01-01";
|
||||
const endDate = "2020-01-30";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateReservationDetailsReport.beginByBillingAccountIdAndWait(
|
||||
billingAccountId,
|
||||
startDate,
|
||||
endDate
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
reservationDetails();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the reservations details report for provided date range asynchronously by billing profile. The Reservation usage details can be viewed by only certain enterprise roles by default. For more details on the roles see, https://docs.microsoft.com/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access
|
||||
*
|
||||
* @summary Generates the reservations details report for provided date range asynchronously by billing profile. The Reservation usage details can be viewed by only certain enterprise roles by default. For more details on the roles see, https://docs.microsoft.com/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateReservationDetailsReportByBillingProfile.json
|
||||
*/
|
||||
async function reservationDetails() {
|
||||
const billingAccountId = "00000000-0000-0000-0000-000000000000";
|
||||
const billingProfileId = "CZSFR-SDFXC-DSDF";
|
||||
const startDate = "2020-01-01";
|
||||
const endDate = "2020-01-30";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateReservationDetailsReport.beginByBillingProfileIdAndWait(
|
||||
billingAccountId,
|
||||
billingProfileId,
|
||||
startDate,
|
||||
endDate
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
reservationDetails();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists all of the available cost management REST API operations.
|
||||
*
|
||||
* @summary Lists all of the available cost management REST API operations.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/OperationList.json
|
||||
*/
|
||||
async function operationList() {
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.operations.list()) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
operationList();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets a URL to download the current month's pricesheet for a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to Azure product growth, the Azure price sheet download experience in this preview version will be updated from a single csv file to a Zip file containing multiple csv files, each with max 200k records.
|
||||
*
|
||||
* @summary Gets a URL to download the current month's pricesheet for a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to Azure product growth, the Azure price sheet download experience in this preview version will be updated from a single csv file to a Zip file containing multiple csv files, each with max 200k records.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PricesheetDownloadByBillingProfile.json
|
||||
*/
|
||||
async function pricesheetDownloadByBillingProfile() {
|
||||
const billingAccountName =
|
||||
"7c05a543-80ff-571e-9f98-1063b3b53cf2:99ad03ad-2d1b-4889-a452-090ad407d25f_2019-05-31";
|
||||
const billingProfileName = "2USN-TPCD-BG7-TGB";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.priceSheet.beginDownloadByBillingProfileAndWait(
|
||||
billingAccountName,
|
||||
billingProfileName
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
pricesheetDownloadByBillingProfile();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets a URL to download the pricesheet for an invoice. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
|
||||
*
|
||||
* @summary Gets a URL to download the pricesheet for an invoice. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PricesheetDownload.json
|
||||
*/
|
||||
async function pricesheetDownload() {
|
||||
const billingAccountName =
|
||||
"7c05a543-80ff-571e-9f98-1063b3b53cf2:99ad03ad-2d1b-4889-a452-090ad407d25f_2019-05-31";
|
||||
const billingProfileName = "2USN-TPCD-BG7-TGB";
|
||||
const invoiceName = "T000940677";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.priceSheet.beginDownloadAndWait(
|
||||
billingAccountName,
|
||||
billingProfileName,
|
||||
invoiceName
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
pricesheetDownload();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
QueryDefinition,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for external cloud provider type defined.
|
||||
*
|
||||
* @summary Query the usage data for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountsQuery.json
|
||||
*/
|
||||
async function externalBillingAccountQueryList() {
|
||||
const externalCloudProviderType = "externalBillingAccounts";
|
||||
const externalCloudProviderId = "100";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usageByExternalCloudProviderType(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for external cloud provider type defined.
|
||||
*
|
||||
* @summary Query the usage data for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionsQuery.json
|
||||
*/
|
||||
async function externalSubscriptionsQuery() {
|
||||
const externalCloudProviderType = "externalSubscriptions";
|
||||
const externalCloudProviderId = "100";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usageByExternalCloudProviderType(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
externalBillingAccountQueryList();
|
||||
externalSubscriptionsQuery();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,785 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
QueryDefinition,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountQuery.json
|
||||
*/
|
||||
async function billingAccountQueryLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/70664866";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountQuery.json
|
||||
*/
|
||||
async function billingAccountQueryMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountQueryGrouping.json
|
||||
*/
|
||||
async function billingAccountQueryGroupingLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/70664866";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }]
|
||||
},
|
||||
timeframe: "TheLastMonth"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountQueryGrouping.json
|
||||
*/
|
||||
async function billingAccountQueryGroupingMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }]
|
||||
},
|
||||
timeframe: "TheLastMonth"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileQuery.json
|
||||
*/
|
||||
async function billingProfileQueryMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileQueryGrouping.json
|
||||
*/
|
||||
async function billingProfileQueryGroupingMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }]
|
||||
},
|
||||
timeframe: "TheLastMonth"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerQuery.json
|
||||
*/
|
||||
async function customerQueryMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerQueryGrouping.json
|
||||
*/
|
||||
async function customerQueryGroupingMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }]
|
||||
},
|
||||
timeframe: "TheLastMonth"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentQuery.json
|
||||
*/
|
||||
async function departmentQueryLegacy() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/departments/123";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentQueryGrouping.json
|
||||
*/
|
||||
async function departmentQueryGroupingLegacy() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/departments/123";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }]
|
||||
},
|
||||
timeframe: "TheLastMonth"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountQuery.json
|
||||
*/
|
||||
async function enrollmentAccountQueryLegacy() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountQueryGrouping.json
|
||||
*/
|
||||
async function enrollmentAccountQueryGroupingLegacy() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "Daily",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }]
|
||||
},
|
||||
timeframe: "TheLastMonth"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionQuery.json
|
||||
*/
|
||||
async function invoiceSectionQueryMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionQueryGrouping.json
|
||||
*/
|
||||
async function invoiceSectionQueryGroupingMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }]
|
||||
},
|
||||
timeframe: "TheLastMonth"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupQuery.json
|
||||
*/
|
||||
async function managementGroupQueryLegacy() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/MyMgId";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupQueryGrouping.json
|
||||
*/
|
||||
async function managementGroupQueryGroupingLegacy() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/MyMgId";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }]
|
||||
},
|
||||
timeframe: "TheLastMonth"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupQuery.json
|
||||
*/
|
||||
async function resourceGroupQueryLegacy() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupQueryGrouping.json
|
||||
*/
|
||||
async function resourceGroupQueryGroupingLegacy() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "Daily",
|
||||
grouping: [{ name: "ResourceType", type: "Dimension" }]
|
||||
},
|
||||
timeframe: "TheLastMonth"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionQuery.json
|
||||
*/
|
||||
async function subscriptionQueryLegacy() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"]
|
||||
}
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
granularity: "Daily"
|
||||
},
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionQueryGrouping.json
|
||||
*/
|
||||
async function subscriptionQueryGroupingLegacy() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const parameters: QueryDefinition = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }]
|
||||
},
|
||||
timeframe: "TheLastMonth"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
billingAccountQueryLegacy();
|
||||
billingAccountQueryMca();
|
||||
billingAccountQueryGroupingLegacy();
|
||||
billingAccountQueryGroupingMca();
|
||||
billingProfileQueryMca();
|
||||
billingProfileQueryGroupingMca();
|
||||
customerQueryMca();
|
||||
customerQueryGroupingMca();
|
||||
departmentQueryLegacy();
|
||||
departmentQueryGroupingLegacy();
|
||||
enrollmentAccountQueryLegacy();
|
||||
enrollmentAccountQueryGroupingLegacy();
|
||||
invoiceSectionQueryMca();
|
||||
invoiceSectionQueryGroupingMca();
|
||||
managementGroupQueryLegacy();
|
||||
managementGroupQueryGroupingLegacy();
|
||||
resourceGroupQueryLegacy();
|
||||
resourceGroupQueryGroupingLegacy();
|
||||
subscriptionQueryLegacy();
|
||||
subscriptionQueryGroupingLegacy();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
CheckNameAvailabilityRequest,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Checks availability and correctness of the name for a scheduled action within the given scope.
|
||||
*
|
||||
* @summary Checks availability and correctness of the name for a scheduled action within the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/checkNameAvailability-shared-scheduledAction.json
|
||||
*/
|
||||
async function scheduledActionCheckNameAvailabilityByScope() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const checkNameAvailabilityRequest: CheckNameAvailabilityRequest = {
|
||||
name: "testName",
|
||||
type: "Microsoft.CostManagement/ScheduledActions"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.checkNameAvailabilityByScope(
|
||||
scope,
|
||||
checkNameAvailabilityRequest
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
scheduledActionCheckNameAvailabilityByScope();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
CheckNameAvailabilityRequest,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Checks availability and correctness of the name for a scheduled action.
|
||||
*
|
||||
* @summary Checks availability and correctness of the name for a scheduled action.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/checkNameAvailability-private-scheduledAction.json
|
||||
*/
|
||||
async function scheduledActionCheckNameAvailability() {
|
||||
const checkNameAvailabilityRequest: CheckNameAvailabilityRequest = {
|
||||
name: "testName",
|
||||
type: "Microsoft.CostManagement/ScheduledActions"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.checkNameAvailability(
|
||||
checkNameAvailabilityRequest
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
scheduledActionCheckNameAvailability();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
ScheduledAction,
|
||||
ScheduledActionsCreateOrUpdateByScopeOptionalParams,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Create or update a shared scheduled action within the given scope.
|
||||
*
|
||||
* @summary Create or update a shared scheduled action within the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-insightAlert-createOrUpdate-shared.json
|
||||
*/
|
||||
async function createOrUpdateInsightAlertScheduledActionByScope() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const name = "dailyAnomalyByResource";
|
||||
const ifMatch = "";
|
||||
const scheduledAction: ScheduledAction = {
|
||||
displayName: "Daily anomaly by resource",
|
||||
kind: "InsightAlert",
|
||||
notification: {
|
||||
subject: "Cost anomaly detected in the resource",
|
||||
to: ["user@gmail.com", "team@gmail.com"]
|
||||
},
|
||||
schedule: {
|
||||
endDate: new Date("2021-06-19T22:21:51.1287144Z"),
|
||||
frequency: "Daily",
|
||||
startDate: new Date("2020-06-19T22:21:51.1287144Z")
|
||||
},
|
||||
status: "Enabled",
|
||||
viewId: "/providers/Microsoft.CostManagement/views/swaggerExample"
|
||||
};
|
||||
const options: ScheduledActionsCreateOrUpdateByScopeOptionalParams = {
|
||||
ifMatch
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.createOrUpdateByScope(
|
||||
scope,
|
||||
name,
|
||||
scheduledAction,
|
||||
options
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Create or update a shared scheduled action within the given scope.
|
||||
*
|
||||
* @summary Create or update a shared scheduled action within the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-createOrUpdate-shared.json
|
||||
*/
|
||||
async function createOrUpdateScheduledActionByScope() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const name = "monthlyCostByResource";
|
||||
const ifMatch = "";
|
||||
const scheduledAction: ScheduledAction = {
|
||||
displayName: "Monthly Cost By Resource",
|
||||
fileDestination: { fileFormats: ["Csv"] },
|
||||
kind: "Email",
|
||||
notification: {
|
||||
subject: "Cost by resource this month",
|
||||
to: ["user@gmail.com", "team@gmail.com"]
|
||||
},
|
||||
schedule: {
|
||||
daysOfWeek: ["Monday"],
|
||||
endDate: new Date("2021-06-19T22:21:51.1287144Z"),
|
||||
frequency: "Monthly",
|
||||
hourOfDay: 10,
|
||||
startDate: new Date("2020-06-19T22:21:51.1287144Z"),
|
||||
weeksOfMonth: ["First", "Third"]
|
||||
},
|
||||
status: "Enabled",
|
||||
viewId: "/providers/Microsoft.CostManagement/views/swaggerExample"
|
||||
};
|
||||
const options: ScheduledActionsCreateOrUpdateByScopeOptionalParams = {
|
||||
ifMatch
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.createOrUpdateByScope(
|
||||
scope,
|
||||
name,
|
||||
scheduledAction,
|
||||
options
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
createOrUpdateInsightAlertScheduledActionByScope();
|
||||
createOrUpdateScheduledActionByScope();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
ScheduledAction,
|
||||
ScheduledActionsCreateOrUpdateOptionalParams,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Create or update a private scheduled action.
|
||||
*
|
||||
* @summary Create or update a private scheduled action.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-createOrUpdate-private.json
|
||||
*/
|
||||
async function createOrUpdatePrivateScheduledAction() {
|
||||
const name = "monthlyCostByResource";
|
||||
const ifMatch = "";
|
||||
const scheduledAction: ScheduledAction = {
|
||||
displayName: "Monthly Cost By Resource",
|
||||
kind: "Email",
|
||||
notification: {
|
||||
subject: "Cost by resource this month",
|
||||
to: ["user@gmail.com", "team@gmail.com"]
|
||||
},
|
||||
schedule: {
|
||||
daysOfWeek: ["Monday"],
|
||||
endDate: new Date("2021-06-19T22:21:51.1287144Z"),
|
||||
frequency: "Monthly",
|
||||
hourOfDay: 10,
|
||||
startDate: new Date("2020-06-19T22:21:51.1287144Z"),
|
||||
weeksOfMonth: ["First", "Third"]
|
||||
},
|
||||
status: "Enabled",
|
||||
viewId: "/providers/Microsoft.CostManagement/views/swaggerExample"
|
||||
};
|
||||
const options: ScheduledActionsCreateOrUpdateOptionalParams = { ifMatch };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.createOrUpdate(
|
||||
name,
|
||||
scheduledAction,
|
||||
options
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
createOrUpdatePrivateScheduledAction();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Delete a scheduled action within the given scope.
|
||||
*
|
||||
* @summary Delete a scheduled action within the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-delete-shared.json
|
||||
*/
|
||||
async function scheduledActionDeleteByScope() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const name = "monthlyCostByResource";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.deleteByScope(scope, name);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
scheduledActionDeleteByScope();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Delete a private scheduled action.
|
||||
*
|
||||
* @summary Delete a private scheduled action.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-delete-private.json
|
||||
*/
|
||||
async function privateScheduledActionDelete() {
|
||||
const name = "monthlyCostByResource";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.delete(name);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
privateScheduledActionDelete();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Get the shared scheduled action from the given scope by name.
|
||||
*
|
||||
* @summary Get the shared scheduled action from the given scope by name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-get-shared.json
|
||||
*/
|
||||
async function scheduledActionByScope() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const name = "monthlyCostByResource";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.getByScope(scope, name);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
scheduledActionByScope();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Get the private scheduled action by name.
|
||||
*
|
||||
* @summary Get the private scheduled action by name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-get-private.json
|
||||
*/
|
||||
async function privateScheduledAction() {
|
||||
const name = "monthlyCostByResource";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.get(name);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
privateScheduledAction();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
ScheduledActionsListByScopeOptionalParams,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to List all shared scheduled actions within the given scope.
|
||||
*
|
||||
* @summary List all shared scheduled actions within the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-list-shared.json
|
||||
*/
|
||||
async function scheduledActionsListByScope() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.scheduledActions.listByScope(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to List all shared scheduled actions within the given scope.
|
||||
*
|
||||
* @summary List all shared scheduled actions within the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-listWithFilter-shared.json
|
||||
*/
|
||||
async function scheduledActionsListByScopeFilterByViewId() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const filter =
|
||||
"properties/viewId eq '/providers/Microsoft.CostManagement/views/swaggerExample'";
|
||||
const options: ScheduledActionsListByScopeOptionalParams = { filter };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.scheduledActions.listByScope(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
scheduledActionsListByScope();
|
||||
scheduledActionsListByScopeFilterByViewId();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import {
|
||||
ScheduledActionsListOptionalParams,
|
||||
CostManagementClient
|
||||
} from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to List all private scheduled actions.
|
||||
*
|
||||
* @summary List all private scheduled actions.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-list-private.json
|
||||
*/
|
||||
async function privateScheduledActionsList() {
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.scheduledActions.list()) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to List all private scheduled actions.
|
||||
*
|
||||
* @summary List all private scheduled actions.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-listWithFilter-private.json
|
||||
*/
|
||||
async function privateScheduledActionsListFilterByViewId() {
|
||||
const filter =
|
||||
"properties/viewId eq '/providers/Microsoft.CostManagement/views/swaggerExample'";
|
||||
const options: ScheduledActionsListOptionalParams = { filter };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.scheduledActions.list(options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
privateScheduledActionsList();
|
||||
privateScheduledActionsListFilterByViewId();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Runs a shared scheduled action within the given scope.
|
||||
*
|
||||
* @summary Runs a shared scheduled action within the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-sendNow-shared.json
|
||||
*/
|
||||
async function scheduledActionRunByScope() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const name = "monthlyCostByResource";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.runByScope(scope, name);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
scheduledActionRunByScope();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Processes a private scheduled action.
|
||||
*
|
||||
* @summary Processes a private scheduled action.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-sendNow-private.json
|
||||
*/
|
||||
async function scheduledActionSendNow() {
|
||||
const name = "monthlyCostByResource";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.run(name);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
scheduledActionSendNow();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { View, CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewCreateOrUpdateByResourceGroup.json
|
||||
*/
|
||||
async function resourceGroupCreateOrUpdateView() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const viewName = "swaggerExample";
|
||||
const parameters: View = {
|
||||
typePropertiesQueryType: "Usage",
|
||||
accumulated: "true",
|
||||
chart: "Table",
|
||||
dataSet: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "Daily",
|
||||
grouping: [],
|
||||
sorting: [{ name: "UsageDate", direction: "Ascending" }]
|
||||
},
|
||||
displayName: "swagger Example",
|
||||
eTag: '"1d4ff9fe66f1d10"',
|
||||
kpis: [
|
||||
{ type: "Forecast", enabled: true, id: undefined },
|
||||
{
|
||||
type: "Budget",
|
||||
enabled: true,
|
||||
id:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"
|
||||
}
|
||||
],
|
||||
metric: "ActualCost",
|
||||
pivots: [
|
||||
{ name: "ServiceName", type: "Dimension" },
|
||||
{ name: "MeterCategory", type: "Dimension" },
|
||||
{ name: "swaggerTagKey", type: "TagKey" }
|
||||
],
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.views.createOrUpdateByScope(
|
||||
scope,
|
||||
viewName,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
resourceGroupCreateOrUpdateView();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { View, CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewCreateOrUpdate.json
|
||||
*/
|
||||
async function createOrUpdatePrivateView() {
|
||||
const viewName = "swaggerExample";
|
||||
const parameters: View = {
|
||||
typePropertiesQueryType: "Usage",
|
||||
accumulated: "true",
|
||||
chart: "Table",
|
||||
dataSet: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "Daily",
|
||||
grouping: [],
|
||||
sorting: [{ name: "UsageDate", direction: "Ascending" }]
|
||||
},
|
||||
displayName: "swagger Example",
|
||||
eTag: '"1d4ff9fe66f1d10"',
|
||||
kpis: [
|
||||
{ type: "Forecast", enabled: true, id: undefined },
|
||||
{
|
||||
type: "Budget",
|
||||
enabled: true,
|
||||
id:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"
|
||||
}
|
||||
],
|
||||
metric: "ActualCost",
|
||||
pivots: [
|
||||
{ name: "ServiceName", type: "Dimension" },
|
||||
{ name: "MeterCategory", type: "Dimension" },
|
||||
{ name: "swaggerTagKey", type: "TagKey" }
|
||||
],
|
||||
timeframe: "MonthToDate"
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.views.createOrUpdate(viewName, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
createOrUpdatePrivateView();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a view.
|
||||
*
|
||||
* @summary The operation to delete a view.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewDeleteByResourceGroup.json
|
||||
*/
|
||||
async function resourceGroupDeleteView() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const viewName = "TestView";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.views.deleteByScope(scope, viewName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
resourceGroupDeleteView();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a view.
|
||||
*
|
||||
* @summary The operation to delete a view.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewDelete.json
|
||||
*/
|
||||
async function deletePrivateView() {
|
||||
const viewName = "TestView";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.views.delete(viewName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
deletePrivateView();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets the view for the defined scope by view name.
|
||||
*
|
||||
* @summary Gets the view for the defined scope by view name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewByResourceGroup.json
|
||||
*/
|
||||
async function resourceGroupView() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const viewName = "swaggerExample";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.views.getByScope(scope, viewName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
resourceGroupView();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets the view by view name.
|
||||
*
|
||||
* @summary Gets the view by view name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateView.json
|
||||
*/
|
||||
async function privateView() {
|
||||
const viewName = "swaggerExample";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.views.get(viewName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
privateView();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists all views at the given scope.
|
||||
*
|
||||
* @summary Lists all views at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewListByResourceGroup.json
|
||||
*/
|
||||
async function resourceGroupViewList() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.views.listByScope(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
resourceGroupViewList();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { CostManagementClient } from "@azure/arm-costmanagement";
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists all views by tenant and object.
|
||||
*
|
||||
* @summary Lists all views by tenant and object.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewList.json
|
||||
*/
|
||||
async function privateViewList() {
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.views.list()) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
privateViewList();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,150 @@
|
|||
# client library samples for JavaScript (Beta)
|
||||
|
||||
These sample programs show how to use the JavaScript client libraries for in some common scenarios.
|
||||
|
||||
| **File Name** | **Description** |
|
||||
| ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [alertsDismissSample.js][alertsdismisssample] | Dismisses the specified alert x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DismissResourceGroupAlerts.json |
|
||||
| [alertsGetSample.js][alertsgetsample] | Gets the alert for the scope by alert ID. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SingleResourceGroupAlert.json |
|
||||
| [alertsListExternalSample.js][alertslistexternalsample] | Lists the Alerts for external cloud provider type defined. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountAlerts.json |
|
||||
| [alertsListSample.js][alertslistsample] | Lists the alerts for scope defined. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountAlerts.json |
|
||||
| [benefitRecommendationsListSample.js][benefitrecommendationslistsample] | List of recommendations for purchasing savings plan. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitRecommendationsByBillingAccount.json |
|
||||
| [benefitUtilizationSummariesListByBillingAccountIdSample.js][benefitutilizationsummarieslistbybillingaccountidsample] | Lists savings plan utilization summaries for the enterprise agreement scope. Supported at grain values: 'Daily' and 'Monthly'. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-BillingAccount.json |
|
||||
| [benefitUtilizationSummariesListByBillingProfileIdSample.js][benefitutilizationsummarieslistbybillingprofileidsample] | Lists savings plan utilization summaries for billing profile. Supported at grain values: 'Daily' and 'Monthly'. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-BillingProfile.json |
|
||||
| [benefitUtilizationSummariesListBySavingsPlanIdSample.js][benefitutilizationsummarieslistbysavingsplanidsample] | Lists the savings plan utilization summaries for daily or monthly grain. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanId-Monthly.json |
|
||||
| [benefitUtilizationSummariesListBySavingsPlanOrderSample.js][benefitutilizationsummarieslistbysavingsplanordersample] | Lists the savings plan utilization summaries for daily or monthly grain. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanOrderId-Daily.json |
|
||||
| [dimensionsByExternalCloudProviderTypeSample.js][dimensionsbyexternalcloudprovidertypesample] | Lists the dimensions by the external cloud provider type. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountsDimensions.json |
|
||||
| [dimensionsListSample.js][dimensionslistsample] | Lists the dimensions by the defined scope. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsList.json |
|
||||
| [exportsCreateOrUpdateSample.js][exportscreateorupdatesample] | The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByBillingAccount.json |
|
||||
| [exportsDeleteSample.js][exportsdeletesample] | The operation to delete a export. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByBillingAccount.json |
|
||||
| [exportsExecuteSample.js][exportsexecutesample] | The operation to run an export. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByBillingAccount.json |
|
||||
| [exportsGetExecutionHistorySample.js][exportsgetexecutionhistorysample] | The operation to get the run history of an export for the defined scope and export name. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByBillingAccount.json |
|
||||
| [exportsGetSample.js][exportsgetsample] | The operation to get the export for the defined scope by export name. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByBillingAccount.json |
|
||||
| [exportsListSample.js][exportslistsample] | The operation to list all exports at the given scope. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByBillingAccount.json |
|
||||
| [forecastExternalCloudProviderUsageSample.js][forecastexternalcloudproviderusagesample] | Lists the forecast charges for external cloud provider type defined. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountForecast.json |
|
||||
| [forecastUsageSample.js][forecastusagesample] | Lists the forecast charges for scope defined. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountForecast.json |
|
||||
| [generateCostDetailsReportCreateOperationSample.js][generatecostdetailsreportcreateoperationsample] | This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod.json |
|
||||
| [generateCostDetailsReportGetOperationResultsSample.js][generatecostdetailsreportgetoperationresultssample] | Get the result of the specified operation. This link is provided in the CostDetails creation request response Location header. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/CostDetailsOperationResultsBySubscriptionScope.json |
|
||||
| [generateDetailedCostReportCreateOperationSample.js][generatedetailedcostreportcreateoperationsample] | Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingAccountLegacyAndBillingPeriod.json |
|
||||
| [generateDetailedCostReportOperationResultsGetSample.js][generatedetailedcostreportoperationresultsgetsample] | Gets the result of the specified operation. The link with this operationId is provided as a response header of the initial request. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportOperationResultsBySubscriptionScope.json |
|
||||
| [generateDetailedCostReportOperationStatusGetSample.js][generatedetailedcostreportoperationstatusgetsample] | Get the status of the specified operation. This link is provided in the GenerateDetailedCostReport creation request response header. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportOperationStatusBySubscriptionScope.json |
|
||||
| [generateReservationDetailsReportByBillingAccountIdSample.js][generatereservationdetailsreportbybillingaccountidsample] | Generates the reservations details report for provided date range asynchronously based on enrollment id. The Reservation usage details can be viewed only by certain enterprise roles. For more details on the roles see, https://docs.microsoft.com/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateReservationDetailsReportByBillingAccount.json |
|
||||
| [generateReservationDetailsReportByBillingProfileIdSample.js][generatereservationdetailsreportbybillingprofileidsample] | Generates the reservations details report for provided date range asynchronously by billing profile. The Reservation usage details can be viewed by only certain enterprise roles by default. For more details on the roles see, https://docs.microsoft.com/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateReservationDetailsReportByBillingProfile.json |
|
||||
| [operationsListSample.js][operationslistsample] | Lists all of the available cost management REST API operations. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/OperationList.json |
|
||||
| [priceSheetDownloadByBillingProfileSample.js][pricesheetdownloadbybillingprofilesample] | Gets a URL to download the current month's pricesheet for a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to Azure product growth, the Azure price sheet download experience in this preview version will be updated from a single csv file to a Zip file containing multiple csv files, each with max 200k records. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PricesheetDownloadByBillingProfile.json |
|
||||
| [priceSheetDownloadSample.js][pricesheetdownloadsample] | Gets a URL to download the pricesheet for an invoice. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PricesheetDownload.json |
|
||||
| [queryUsageByExternalCloudProviderTypeSample.js][queryusagebyexternalcloudprovidertypesample] | Query the usage data for external cloud provider type defined. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountsQuery.json |
|
||||
| [queryUsageSample.js][queryusagesample] | Query the usage data for scope defined. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountQuery.json |
|
||||
| [scheduledActionsCheckNameAvailabilityByScopeSample.js][scheduledactionschecknameavailabilitybyscopesample] | Checks availability and correctness of the name for a scheduled action within the given scope. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/checkNameAvailability-shared-scheduledAction.json |
|
||||
| [scheduledActionsCheckNameAvailabilitySample.js][scheduledactionschecknameavailabilitysample] | Checks availability and correctness of the name for a scheduled action. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/checkNameAvailability-private-scheduledAction.json |
|
||||
| [scheduledActionsCreateOrUpdateByScopeSample.js][scheduledactionscreateorupdatebyscopesample] | Create or update a shared scheduled action within the given scope. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-insightAlert-createOrUpdate-shared.json |
|
||||
| [scheduledActionsCreateOrUpdateSample.js][scheduledactionscreateorupdatesample] | Create or update a private scheduled action. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-createOrUpdate-private.json |
|
||||
| [scheduledActionsDeleteByScopeSample.js][scheduledactionsdeletebyscopesample] | Delete a scheduled action within the given scope. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-delete-shared.json |
|
||||
| [scheduledActionsDeleteSample.js][scheduledactionsdeletesample] | Delete a private scheduled action. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-delete-private.json |
|
||||
| [scheduledActionsGetByScopeSample.js][scheduledactionsgetbyscopesample] | Get the shared scheduled action from the given scope by name. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-get-shared.json |
|
||||
| [scheduledActionsGetSample.js][scheduledactionsgetsample] | Get the private scheduled action by name. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-get-private.json |
|
||||
| [scheduledActionsListByScopeSample.js][scheduledactionslistbyscopesample] | List all shared scheduled actions within the given scope. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-list-shared.json |
|
||||
| [scheduledActionsListSample.js][scheduledactionslistsample] | List all private scheduled actions. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-list-private.json |
|
||||
| [scheduledActionsRunByScopeSample.js][scheduledactionsrunbyscopesample] | Runs a shared scheduled action within the given scope. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-sendNow-shared.json |
|
||||
| [scheduledActionsRunSample.js][scheduledactionsrunsample] | Processes a private scheduled action. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-sendNow-private.json |
|
||||
| [viewsCreateOrUpdateByScopeSample.js][viewscreateorupdatebyscopesample] | The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewCreateOrUpdateByResourceGroup.json |
|
||||
| [viewsCreateOrUpdateSample.js][viewscreateorupdatesample] | The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewCreateOrUpdate.json |
|
||||
| [viewsDeleteByScopeSample.js][viewsdeletebyscopesample] | The operation to delete a view. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewDeleteByResourceGroup.json |
|
||||
| [viewsDeleteSample.js][viewsdeletesample] | The operation to delete a view. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewDelete.json |
|
||||
| [viewsGetByScopeSample.js][viewsgetbyscopesample] | Gets the view for the defined scope by view name. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewByResourceGroup.json |
|
||||
| [viewsGetSample.js][viewsgetsample] | Gets the view by view name. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateView.json |
|
||||
| [viewsListByScopeSample.js][viewslistbyscopesample] | Lists all views at the given scope. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewListByResourceGroup.json |
|
||||
| [viewsListSample.js][viewslistsample] | Lists all views by tenant and object. x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewList.json |
|
||||
|
||||
## Prerequisites
|
||||
|
||||
The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule).
|
||||
|
||||
You need [an Azure subscription][freesub] to run these sample programs.
|
||||
|
||||
Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function.
|
||||
|
||||
Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package].
|
||||
|
||||
## Setup
|
||||
|
||||
To run the samples using the published version of the package:
|
||||
|
||||
1. Install the dependencies using `npm`:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically.
|
||||
|
||||
3. Run whichever samples you like (note that some samples may require additional setup, see the table above):
|
||||
|
||||
```bash
|
||||
node alertsDismissSample.js
|
||||
```
|
||||
|
||||
Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform):
|
||||
|
||||
```bash
|
||||
npx cross-env node alertsDismissSample.js
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients.
|
||||
|
||||
[alertsdismisssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/alertsDismissSample.js
|
||||
[alertsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/alertsGetSample.js
|
||||
[alertslistexternalsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/alertsListExternalSample.js
|
||||
[alertslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/alertsListSample.js
|
||||
[benefitrecommendationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/benefitRecommendationsListSample.js
|
||||
[benefitutilizationsummarieslistbybillingaccountidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/benefitUtilizationSummariesListByBillingAccountIdSample.js
|
||||
[benefitutilizationsummarieslistbybillingprofileidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/benefitUtilizationSummariesListByBillingProfileIdSample.js
|
||||
[benefitutilizationsummarieslistbysavingsplanidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/benefitUtilizationSummariesListBySavingsPlanIdSample.js
|
||||
[benefitutilizationsummarieslistbysavingsplanordersample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/benefitUtilizationSummariesListBySavingsPlanOrderSample.js
|
||||
[dimensionsbyexternalcloudprovidertypesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/dimensionsByExternalCloudProviderTypeSample.js
|
||||
[dimensionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/dimensionsListSample.js
|
||||
[exportscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/exportsCreateOrUpdateSample.js
|
||||
[exportsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/exportsDeleteSample.js
|
||||
[exportsexecutesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/exportsExecuteSample.js
|
||||
[exportsgetexecutionhistorysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/exportsGetExecutionHistorySample.js
|
||||
[exportsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/exportsGetSample.js
|
||||
[exportslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/exportsListSample.js
|
||||
[forecastexternalcloudproviderusagesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/forecastExternalCloudProviderUsageSample.js
|
||||
[forecastusagesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/forecastUsageSample.js
|
||||
[generatecostdetailsreportcreateoperationsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/generateCostDetailsReportCreateOperationSample.js
|
||||
[generatecostdetailsreportgetoperationresultssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/generateCostDetailsReportGetOperationResultsSample.js
|
||||
[generatedetailedcostreportcreateoperationsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/generateDetailedCostReportCreateOperationSample.js
|
||||
[generatedetailedcostreportoperationresultsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/generateDetailedCostReportOperationResultsGetSample.js
|
||||
[generatedetailedcostreportoperationstatusgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/generateDetailedCostReportOperationStatusGetSample.js
|
||||
[generatereservationdetailsreportbybillingaccountidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/generateReservationDetailsReportByBillingAccountIdSample.js
|
||||
[generatereservationdetailsreportbybillingprofileidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/generateReservationDetailsReportByBillingProfileIdSample.js
|
||||
[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/operationsListSample.js
|
||||
[pricesheetdownloadbybillingprofilesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/priceSheetDownloadByBillingProfileSample.js
|
||||
[pricesheetdownloadsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/priceSheetDownloadSample.js
|
||||
[queryusagebyexternalcloudprovidertypesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/queryUsageByExternalCloudProviderTypeSample.js
|
||||
[queryusagesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/queryUsageSample.js
|
||||
[scheduledactionschecknameavailabilitybyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsCheckNameAvailabilityByScopeSample.js
|
||||
[scheduledactionschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsCheckNameAvailabilitySample.js
|
||||
[scheduledactionscreateorupdatebyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsCreateOrUpdateByScopeSample.js
|
||||
[scheduledactionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsCreateOrUpdateSample.js
|
||||
[scheduledactionsdeletebyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsDeleteByScopeSample.js
|
||||
[scheduledactionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsDeleteSample.js
|
||||
[scheduledactionsgetbyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsGetByScopeSample.js
|
||||
[scheduledactionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsGetSample.js
|
||||
[scheduledactionslistbyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsListByScopeSample.js
|
||||
[scheduledactionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsListSample.js
|
||||
[scheduledactionsrunbyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsRunByScopeSample.js
|
||||
[scheduledactionsrunsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/scheduledActionsRunSample.js
|
||||
[viewscreateorupdatebyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/viewsCreateOrUpdateByScopeSample.js
|
||||
[viewscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/viewsCreateOrUpdateSample.js
|
||||
[viewsdeletebyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/viewsDeleteByScopeSample.js
|
||||
[viewsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/viewsDeleteSample.js
|
||||
[viewsgetbyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/viewsGetByScopeSample.js
|
||||
[viewsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/viewsGetSample.js
|
||||
[viewslistbyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/viewsListByScopeSample.js
|
||||
[viewslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cost-management/arm-costmanagement/samples/v1-beta/javascript/viewsListSample.js
|
||||
[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-costmanagement?view=azure-node-preview
|
||||
[freesub]: https://azure.microsoft.com/free/
|
||||
[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cost-management/arm-costmanagement/README.md
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Dismisses the specified alert
|
||||
*
|
||||
* @summary Dismisses the specified alert
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DismissResourceGroupAlerts.json
|
||||
*/
|
||||
async function patchResourceGroupAlerts() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const alertId = "22222222-2222-2222-2222-222222222222";
|
||||
const parameters = { status: "Dismissed" };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.dismiss(scope, alertId, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Dismisses the specified alert
|
||||
*
|
||||
* @summary Dismisses the specified alert
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DismissSubscriptionAlerts.json
|
||||
*/
|
||||
async function patchSubscriptionAlerts() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const alertId = "22222222-2222-2222-2222-222222222222";
|
||||
const parameters = { status: "Dismissed" };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.dismiss(scope, alertId, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
patchResourceGroupAlerts();
|
||||
patchSubscriptionAlerts();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets the alert for the scope by alert ID.
|
||||
*
|
||||
* @summary Gets the alert for the scope by alert ID.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SingleResourceGroupAlert.json
|
||||
*/
|
||||
async function singleResourceGroupAlerts() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const alertId = "22222222-2222-2222-2222-222222222222";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.get(scope, alertId);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets the alert for the scope by alert ID.
|
||||
*
|
||||
* @summary Gets the alert for the scope by alert ID.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SingleSubscriptionAlert.json
|
||||
*/
|
||||
async function singleSubscriptionAlerts() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const alertId = "22222222-2222-2222-2222-222222222222";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.get(scope, alertId);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
singleResourceGroupAlerts();
|
||||
singleSubscriptionAlerts();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the Alerts for external cloud provider type defined.
|
||||
*
|
||||
* @summary Lists the Alerts for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountAlerts.json
|
||||
*/
|
||||
async function externalBillingAccountAlerts() {
|
||||
const externalCloudProviderType = "externalBillingAccounts";
|
||||
const externalCloudProviderId = "100";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.listExternal(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the Alerts for external cloud provider type defined.
|
||||
*
|
||||
* @summary Lists the Alerts for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionAlerts.json
|
||||
*/
|
||||
async function externalSubscriptionAlerts() {
|
||||
const externalCloudProviderType = "externalSubscriptions";
|
||||
const externalCloudProviderId = "100";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.listExternal(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
externalBillingAccountAlerts();
|
||||
externalSubscriptionAlerts();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountAlerts.json
|
||||
*/
|
||||
async function billingAccountAlerts() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingProfileAlerts.json
|
||||
*/
|
||||
async function billingProfileAlerts() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentAlerts.json
|
||||
*/
|
||||
async function departmentAlerts() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountAlerts.json
|
||||
*/
|
||||
async function enrollmentAccountAlerts() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/InvoiceSectionAlerts.json
|
||||
*/
|
||||
async function invoiceSectionAlerts() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupAlerts.json
|
||||
*/
|
||||
async function resourceGroupAlerts() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the alerts for scope defined.
|
||||
*
|
||||
* @summary Lists the alerts for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionAlerts.json
|
||||
*/
|
||||
async function subscriptionAlerts() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.alerts.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
billingAccountAlerts();
|
||||
billingProfileAlerts();
|
||||
departmentAlerts();
|
||||
enrollmentAccountAlerts();
|
||||
invoiceSectionAlerts();
|
||||
resourceGroupAlerts();
|
||||
subscriptionAlerts();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to List of recommendations for purchasing savings plan.
|
||||
*
|
||||
* @summary List of recommendations for purchasing savings plan.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitRecommendationsByBillingAccount.json
|
||||
*/
|
||||
async function benefitRecommendationsBillingAccountList() {
|
||||
const filter = "properties/lookBackPeriod eq 'Last7Days' AND properties/term eq 'P1Y'";
|
||||
const expand = "properties/usage,properties/allRecommendationDetails";
|
||||
const billingScope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const options = { filter, expand };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.benefitRecommendations.list(billingScope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
benefitRecommendationsBillingAccountList();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists savings plan utilization summaries for the enterprise agreement scope. Supported at grain values: 'Daily' and 'Monthly'.
|
||||
*
|
||||
* @summary Lists savings plan utilization summaries for the enterprise agreement scope. Supported at grain values: 'Daily' and 'Monthly'.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-BillingAccount.json
|
||||
*/
|
||||
async function savingsPlanUtilizationSummariesBillingAccount() {
|
||||
const billingAccountId = "12345";
|
||||
const filter = "properties/usageDate ge 2022-10-15 and properties/usageDate le 2022-10-18";
|
||||
const options = {
|
||||
filter,
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.benefitUtilizationSummaries.listByBillingAccountId(
|
||||
billingAccountId,
|
||||
options
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
savingsPlanUtilizationSummariesBillingAccount();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists savings plan utilization summaries for billing profile. Supported at grain values: 'Daily' and 'Monthly'.
|
||||
*
|
||||
* @summary Lists savings plan utilization summaries for billing profile. Supported at grain values: 'Daily' and 'Monthly'.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-BillingProfile.json
|
||||
*/
|
||||
async function savingsPlanUtilizationSummariesBillingProfile() {
|
||||
const billingAccountId =
|
||||
"c0a00000-0e04-5ee3-000e-f0c6e00000ec:c0a00000-0e04-5ee3-000e-f0c6e00000ec";
|
||||
const billingProfileId = "200e5e90-000e-4960-8dcd-8d00a02db000";
|
||||
const filter = "properties/usageDate ge 2022-10-15 and properties/usageDate le 2022-10-18";
|
||||
const options = {
|
||||
filter,
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.benefitUtilizationSummaries.listByBillingProfileId(
|
||||
billingAccountId,
|
||||
billingProfileId,
|
||||
options
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
savingsPlanUtilizationSummariesBillingProfile();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the savings plan utilization summaries for daily or monthly grain.
|
||||
*
|
||||
* @summary Lists the savings plan utilization summaries for daily or monthly grain.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanId-Monthly.json
|
||||
*/
|
||||
async function savingsPlanUtilizationSummariesMonthlyWithSavingsPlanId() {
|
||||
const savingsPlanOrderId = "66cccc66-6ccc-6c66-666c-66cc6c6c66c6";
|
||||
const savingsPlanId = "222d22dd-d2d2-2dd2-222d-2dd2222ddddd";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.benefitUtilizationSummaries.listBySavingsPlanId(
|
||||
savingsPlanOrderId,
|
||||
savingsPlanId
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
savingsPlanUtilizationSummariesMonthlyWithSavingsPlanId();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the savings plan utilization summaries for daily or monthly grain.
|
||||
*
|
||||
* @summary Lists the savings plan utilization summaries for daily or monthly grain.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanOrderId-Daily.json
|
||||
*/
|
||||
async function savingsPlanUtilizationSummariesDaily() {
|
||||
const savingsPlanOrderId = "66cccc66-6ccc-6c66-666c-66cc6c6c66c6";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.benefitUtilizationSummaries.listBySavingsPlanOrder(
|
||||
savingsPlanOrderId
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
savingsPlanUtilizationSummariesDaily();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the external cloud provider type.
|
||||
*
|
||||
* @summary Lists the dimensions by the external cloud provider type.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountsDimensions.json
|
||||
*/
|
||||
async function externalBillingAccountDimensionList() {
|
||||
const externalCloudProviderType = "externalBillingAccounts";
|
||||
const externalCloudProviderId = "100";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.listByExternalCloudProviderType(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the external cloud provider type.
|
||||
*
|
||||
* @summary Lists the dimensions by the external cloud provider type.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionsDimensions.json
|
||||
*/
|
||||
async function externalSubscriptionDimensionList() {
|
||||
const externalCloudProviderType = "externalSubscriptions";
|
||||
const externalCloudProviderId = "100";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.listByExternalCloudProviderType(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId
|
||||
)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
externalBillingAccountDimensionList();
|
||||
externalSubscriptionDimensionList();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,551 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsList.json
|
||||
*/
|
||||
async function billingAccountDimensionsListLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountDimensionsList.json
|
||||
*/
|
||||
async function billingAccountDimensionsListMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function billingAccountDimensionsListExpandAndTopLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function billingAccountDimensionsListExpandAndTopMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsListWithFilter.json
|
||||
*/
|
||||
async function billingAccountDimensionsListWithFilterLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountDimensionsListWithFilter.json
|
||||
*/
|
||||
async function billingAccountDimensionsListWithFilterMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileDimensionsList.json
|
||||
*/
|
||||
async function billingProfileDimensionsListMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function billingProfileDimensionsListExpandAndTopMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileDimensionsListWithFilter.json
|
||||
*/
|
||||
async function billingProfileDimensionsListWithFilterMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerDimensionsList.json
|
||||
*/
|
||||
async function customerDimensionsListMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function customerDimensionsListExpandAndTopMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerDimensionsListWithFilter.json
|
||||
*/
|
||||
async function customerDimensionsListWithFilterMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentDimensionsList.json
|
||||
*/
|
||||
async function departmentDimensionsListLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/departments/123";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function departmentDimensionsListExpandAndTopLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/departments/123";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentDimensionsListWithFilter.json
|
||||
*/
|
||||
async function departmentDimensionsListWithFilterLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/departments/123";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountDimensionsList.json
|
||||
*/
|
||||
async function enrollmentAccountDimensionsListLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function enrollmentAccountDimensionsListExpandAndTopLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountDimensionsListWithFilter.json
|
||||
*/
|
||||
async function enrollmentAccountDimensionsListWithFilterLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionDimensionsList.json
|
||||
*/
|
||||
async function invoiceSectionDimensionsListMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function invoiceSectionDimensionsListExpandAndTopMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionDimensionsListWithFilter.json
|
||||
*/
|
||||
async function invoiceSectionDimensionsListWithFilterMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupDimensionsList.json
|
||||
*/
|
||||
async function managementGroupDimensionsListLegacy() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/MyMgId";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupDimensionsListExpandAndTop.json
|
||||
*/
|
||||
async function managementGroupDimensionsListExpandAndTopLegacy() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/MyMgId";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupDimensionsListWithFilter.json
|
||||
*/
|
||||
async function managementGroupDimensionsListWithFilterLegacy() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/MyMgId";
|
||||
const filter = "properties/category eq 'resourceId'";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { filter, expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupDimensionsList.json
|
||||
*/
|
||||
async function resourceGroupDimensionsListLegacy() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/system.orlando";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the dimensions by the defined scope.
|
||||
*
|
||||
* @summary Lists the dimensions by the defined scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionDimensionsList.json
|
||||
*/
|
||||
async function subscriptionDimensionsListLegacy() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const expand = "properties/data";
|
||||
const top = 5;
|
||||
const options = { expand, top };
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.dimensions.list(scope, options)) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
billingAccountDimensionsListLegacy();
|
||||
billingAccountDimensionsListMca();
|
||||
billingAccountDimensionsListExpandAndTopLegacy();
|
||||
billingAccountDimensionsListExpandAndTopMca();
|
||||
billingAccountDimensionsListWithFilterLegacy();
|
||||
billingAccountDimensionsListWithFilterMca();
|
||||
billingProfileDimensionsListMca();
|
||||
billingProfileDimensionsListExpandAndTopMca();
|
||||
billingProfileDimensionsListWithFilterMca();
|
||||
customerDimensionsListMca();
|
||||
customerDimensionsListExpandAndTopMca();
|
||||
customerDimensionsListWithFilterMca();
|
||||
departmentDimensionsListLegacy();
|
||||
departmentDimensionsListExpandAndTopLegacy();
|
||||
departmentDimensionsListWithFilterLegacy();
|
||||
enrollmentAccountDimensionsListLegacy();
|
||||
enrollmentAccountDimensionsListExpandAndTopLegacy();
|
||||
enrollmentAccountDimensionsListWithFilterLegacy();
|
||||
invoiceSectionDimensionsListMca();
|
||||
invoiceSectionDimensionsListExpandAndTopMca();
|
||||
invoiceSectionDimensionsListWithFilterMca();
|
||||
managementGroupDimensionsListLegacy();
|
||||
managementGroupDimensionsListExpandAndTopLegacy();
|
||||
managementGroupDimensionsListWithFilterLegacy();
|
||||
resourceGroupDimensionsListLegacy();
|
||||
subscriptionDimensionsListLegacy();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,288 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByBillingAccount.json
|
||||
*/
|
||||
async function exportCreateOrUpdateByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const exportName = "TestExport";
|
||||
const parameters = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: ["Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity"],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc",
|
||||
},
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z"),
|
||||
},
|
||||
status: "Active",
|
||||
},
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(scope, exportName, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByDepartment.json
|
||||
*/
|
||||
async function exportCreateOrUpdateByDepartment() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234";
|
||||
const exportName = "TestExport";
|
||||
const parameters = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: ["Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity"],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc",
|
||||
},
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z"),
|
||||
},
|
||||
status: "Active",
|
||||
},
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(scope, exportName, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportCreateOrUpdateByEnrollmentAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const exportName = "TestExport";
|
||||
const parameters = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: ["Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity"],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc",
|
||||
},
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z"),
|
||||
},
|
||||
status: "Active",
|
||||
},
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(scope, exportName, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByManagementGroup.json
|
||||
*/
|
||||
async function exportCreateOrUpdateByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const exportName = "TestExport";
|
||||
const parameters = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: ["Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity"],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc",
|
||||
},
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z"),
|
||||
},
|
||||
status: "Active",
|
||||
},
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(scope, exportName, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByResourceGroup.json
|
||||
*/
|
||||
async function exportCreateOrUpdateByResourceGroup() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const exportName = "TestExport";
|
||||
const parameters = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: ["Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity"],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc",
|
||||
},
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z"),
|
||||
},
|
||||
status: "Active",
|
||||
},
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(scope, exportName, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
*
|
||||
* @summary The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateBySubscription.json
|
||||
*/
|
||||
async function exportCreateOrUpdateBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const exportName = "TestExport";
|
||||
const parameters = {
|
||||
format: "Csv",
|
||||
definition: {
|
||||
type: "ActualCost",
|
||||
dataSet: {
|
||||
configuration: {
|
||||
columns: ["Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity"],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
},
|
||||
deliveryInfo: {
|
||||
destination: {
|
||||
container: "exports",
|
||||
resourceId:
|
||||
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
|
||||
rootFolderPath: "ad-hoc",
|
||||
},
|
||||
},
|
||||
schedule: {
|
||||
recurrence: "Weekly",
|
||||
recurrencePeriod: {
|
||||
from: new Date("2020-06-01T00:00:00Z"),
|
||||
to: new Date("2020-10-31T00:00:00Z"),
|
||||
},
|
||||
status: "Active",
|
||||
},
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.createOrUpdate(scope, exportName, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportCreateOrUpdateByBillingAccount();
|
||||
exportCreateOrUpdateByDepartment();
|
||||
exportCreateOrUpdateByEnrollmentAccount();
|
||||
exportCreateOrUpdateByManagementGroup();
|
||||
exportCreateOrUpdateByResourceGroup();
|
||||
exportCreateOrUpdateBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByBillingAccount.json
|
||||
*/
|
||||
async function exportDeleteByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByDepartment.json
|
||||
*/
|
||||
async function exportDeleteByDepartment() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportDeleteByEnrollmentAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByManagementGroup.json
|
||||
*/
|
||||
async function exportDeleteByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByResourceGroup.json
|
||||
*/
|
||||
async function exportDeleteByResourceGroup() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to delete a export.
|
||||
*
|
||||
* @summary The operation to delete a export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteBySubscription.json
|
||||
*/
|
||||
async function exportDeleteBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.delete(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportDeleteByBillingAccount();
|
||||
exportDeleteByDepartment();
|
||||
exportDeleteByEnrollmentAccount();
|
||||
exportDeleteByManagementGroup();
|
||||
exportDeleteByResourceGroup();
|
||||
exportDeleteBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByBillingAccount.json
|
||||
*/
|
||||
async function exportRunByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByDepartment.json
|
||||
*/
|
||||
async function exportRunByDepartment() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportRunByEnrollmentAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByManagementGroup.json
|
||||
*/
|
||||
async function exportRunByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByResourceGroup.json
|
||||
*/
|
||||
async function exportRunByResourceGroup() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to run an export.
|
||||
*
|
||||
* @summary The operation to run an export.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunBySubscription.json
|
||||
*/
|
||||
async function exportRunBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.execute(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportRunByBillingAccount();
|
||||
exportRunByDepartment();
|
||||
exportRunByEnrollmentAccount();
|
||||
exportRunByManagementGroup();
|
||||
exportRunByResourceGroup();
|
||||
exportRunBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByBillingAccount.json
|
||||
*/
|
||||
async function exportRunHistoryGetByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByDepartment.json
|
||||
*/
|
||||
async function exportRunHistoryGetByDepartment() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportRunHistoryGetByEnrollmentAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByManagementGroup.json
|
||||
*/
|
||||
async function exportRunHistoryGetByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByResourceGroup.json
|
||||
*/
|
||||
async function exportRunHistoryGetByResourceGroup() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the run history of an export for the defined scope and export name.
|
||||
*
|
||||
* @summary The operation to get the run history of an export for the defined scope and export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetBySubscription.json
|
||||
*/
|
||||
async function exportRunHistoryGetBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.getExecutionHistory(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportRunHistoryGetByBillingAccount();
|
||||
exportRunHistoryGetByDepartment();
|
||||
exportRunHistoryGetByEnrollmentAccount();
|
||||
exportRunHistoryGetByManagementGroup();
|
||||
exportRunHistoryGetByResourceGroup();
|
||||
exportRunHistoryGetBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByBillingAccount.json
|
||||
*/
|
||||
async function exportGetByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByDepartment.json
|
||||
*/
|
||||
async function exportGetByDepartment() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportGetByEnrollmentAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByManagementGroup.json
|
||||
*/
|
||||
async function exportGetByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByResourceGroup.json
|
||||
*/
|
||||
async function exportGetByResourceGroup() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to get the export for the defined scope by export name.
|
||||
*
|
||||
* @summary The operation to get the export for the defined scope by export name.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetBySubscription.json
|
||||
*/
|
||||
async function exportGetBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const exportName = "TestExport";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.get(scope, exportName);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportGetByBillingAccount();
|
||||
exportGetByDepartment();
|
||||
exportGetByEnrollmentAccount();
|
||||
exportGetByManagementGroup();
|
||||
exportGetByResourceGroup();
|
||||
exportGetBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByBillingAccount.json
|
||||
*/
|
||||
async function exportsGetByBillingAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/123456";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByDepartment.json
|
||||
*/
|
||||
async function exportsGetByDepartment() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12/departments/123";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByEnrollmentAccount.json
|
||||
*/
|
||||
async function exportsGetByEnrollmentAccount() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByManagementGroup.json
|
||||
*/
|
||||
async function exportsGetByManagementGroup() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/TestMG";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByResourceGroup.json
|
||||
*/
|
||||
async function exportsGetByResourceGroup() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to The operation to list all exports at the given scope.
|
||||
*
|
||||
* @summary The operation to list all exports at the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetBySubscription.json
|
||||
*/
|
||||
async function exportsGetBySubscription() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.exports.list(scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
exportsGetByBillingAccount();
|
||||
exportsGetByDepartment();
|
||||
exportsGetByEnrollmentAccount();
|
||||
exportsGetByManagementGroup();
|
||||
exportsGetByResourceGroup();
|
||||
exportsGetBySubscription();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for external cloud provider type defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountForecast.json
|
||||
*/
|
||||
async function externalBillingAccountForecast() {
|
||||
const externalCloudProviderType = "externalBillingAccounts";
|
||||
const externalCloudProviderId = "100";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00"),
|
||||
},
|
||||
timeframe: "Custom",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.externalCloudProviderUsage(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for external cloud provider type defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionForecast.json
|
||||
*/
|
||||
async function externalSubscriptionForecast() {
|
||||
const externalCloudProviderType = "externalSubscriptions";
|
||||
const externalCloudProviderId = "100";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00"),
|
||||
},
|
||||
timeframe: "Custom",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.externalCloudProviderUsage(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
externalBillingAccountForecast();
|
||||
externalSubscriptionForecast();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,426 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountForecast.json
|
||||
*/
|
||||
async function billingAccountForecast() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00"),
|
||||
},
|
||||
timeframe: "Custom",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingProfileForecast.json
|
||||
*/
|
||||
async function billingProfileForecast() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00"),
|
||||
},
|
||||
timeframe: "Custom",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentForecast.json
|
||||
*/
|
||||
async function departmentForecast() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00"),
|
||||
},
|
||||
timeframe: "Custom",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountForecast.json
|
||||
*/
|
||||
async function enrollmentAccountForecast() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00"),
|
||||
},
|
||||
timeframe: "Custom",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/InvoiceSectionForecast.json
|
||||
*/
|
||||
async function invoiceSectionForecast() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00"),
|
||||
},
|
||||
timeframe: "Custom",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupForecast.json
|
||||
*/
|
||||
async function resourceGroupForecast() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00"),
|
||||
},
|
||||
timeframe: "Custom",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists the forecast charges for scope defined.
|
||||
*
|
||||
* @summary Lists the forecast charges for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionForecast.json
|
||||
*/
|
||||
async function subscriptionForecast() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "Cost", function: "Sum" } },
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
includeActualCost: false,
|
||||
includeFreshPartialCost: false,
|
||||
timePeriod: {
|
||||
from: new Date("2022-08-01T00:00:00+00:00"),
|
||||
to: new Date("2022-08-31T23:59:59+00:00"),
|
||||
},
|
||||
timeframe: "Custom",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.forecast.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
billingAccountForecast();
|
||||
billingProfileForecast();
|
||||
departmentForecast();
|
||||
enrollmentAccountForecast();
|
||||
invoiceSectionForecast();
|
||||
resourceGroupForecast();
|
||||
subscriptionForecast();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod.json
|
||||
*/
|
||||
async function generateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345";
|
||||
const parameters = {
|
||||
billingPeriod: "202205",
|
||||
metric: "ActualCost",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingProfileAndInvoiceId.json
|
||||
*/
|
||||
async function generateCostDetailsReportByBillingProfileAndInvoiceId() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters = {
|
||||
invoiceId: "M1234567",
|
||||
metric: "ActualCost",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId.json
|
||||
*/
|
||||
async function generateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579";
|
||||
const parameters = {
|
||||
invoiceId: "M1234567",
|
||||
metric: "ActualCost",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByCustomerAndTimePeriod.json
|
||||
*/
|
||||
async function generateCostDetailsReportByCustomerAndTimePeriod() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579";
|
||||
const parameters = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" },
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByDepartmentsAndTimePeriod.json
|
||||
*/
|
||||
async function generateCostDetailsReportByDepartmentsAndTimePeriod() {
|
||||
const scope = "providers/Microsoft.Billing/departments/12345";
|
||||
const parameters = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" },
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByEnrollmentAccountsAndTimePeriod.json
|
||||
*/
|
||||
async function generateCostDetailsReportByEnrollmentAccountsAndTimePeriod() {
|
||||
const scope = "providers/Microsoft.Billing/enrollmentAccounts/1234";
|
||||
const parameters = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" },
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
*
|
||||
* @summary This API is the replacement for all previously release Usage Details APIs. Request to generate a cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly known as usage details) fields found in files ,see https://learn.microsoft.com/azure/cost-management-billing/automate/understand-usage-details-fields
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportBySubscriptionAndTimePeriod.json
|
||||
*/
|
||||
async function generateCostDetailsReportBySubscriptionAndTimePeriod() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const parameters = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" },
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
generateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod();
|
||||
generateCostDetailsReportByBillingProfileAndInvoiceId();
|
||||
generateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId();
|
||||
generateCostDetailsReportByCustomerAndTimePeriod();
|
||||
generateCostDetailsReportByDepartmentsAndTimePeriod();
|
||||
generateCostDetailsReportByEnrollmentAccountsAndTimePeriod();
|
||||
generateCostDetailsReportBySubscriptionAndTimePeriod();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Get the result of the specified operation. This link is provided in the CostDetails creation request response Location header.
|
||||
*
|
||||
* @summary Get the result of the specified operation. This link is provided in the CostDetails creation request response Location header.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/CostDetailsOperationResultsBySubscriptionScope.json
|
||||
*/
|
||||
async function getDetailsOfTheOperationResult() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const operationId = "00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateCostDetailsReport.beginGetOperationResultsAndWait(
|
||||
scope,
|
||||
operationId
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
getDetailsOfTheOperationResult();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
*
|
||||
* @summary Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingAccountLegacyAndBillingPeriod.json
|
||||
*/
|
||||
async function generateDetailedCostReportByBillingAccountLegacyAndBillingPeriod() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345";
|
||||
const parameters = {
|
||||
billingPeriod: "202008",
|
||||
metric: "ActualCost",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
*
|
||||
* @summary Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingProfileAndInvoiceId.json
|
||||
*/
|
||||
async function generateDetailedCostReportByBillingProfileAndInvoiceId() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters = {
|
||||
invoiceId: "M1234567",
|
||||
metric: "ActualCost",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
*
|
||||
* @summary Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId.json
|
||||
*/
|
||||
async function generateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters = {
|
||||
customerId: "456789",
|
||||
invoiceId: "M1234567",
|
||||
metric: "ActualCost",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
*
|
||||
* @summary Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByCustomerAndTimePeriod.json
|
||||
*/
|
||||
async function generateDetailedCostReportByCustomerAndTimePeriod() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579";
|
||||
const parameters = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" },
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
*
|
||||
* @summary Generates the detailed cost report for provided date range, billing period(only enterprise customers) or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status and if the operation is completed the blob file where generated detailed cost report is being stored.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportBySubscriptionAndTimePeriod.json
|
||||
*/
|
||||
async function generateDetailedCostReportBySubscriptionAndTimePeriod() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const parameters = {
|
||||
metric: "ActualCost",
|
||||
timePeriod: { end: "2020-03-15", start: "2020-03-01" },
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReport.beginCreateOperationAndWait(
|
||||
scope,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
generateDetailedCostReportByBillingAccountLegacyAndBillingPeriod();
|
||||
generateDetailedCostReportByBillingProfileAndInvoiceId();
|
||||
generateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId();
|
||||
generateDetailedCostReportByCustomerAndTimePeriod();
|
||||
generateDetailedCostReportBySubscriptionAndTimePeriod();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets the result of the specified operation. The link with this operationId is provided as a response header of the initial request.
|
||||
*
|
||||
* @summary Gets the result of the specified operation. The link with this operationId is provided as a response header of the initial request.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportOperationResultsBySubscriptionScope.json
|
||||
*/
|
||||
async function getDetailsOfTheOperationResult() {
|
||||
const operationId = "00000000-0000-0000-0000-000000000000";
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReportOperationResults.beginGetAndWait(
|
||||
operationId,
|
||||
scope
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
getDetailsOfTheOperationResult();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Get the status of the specified operation. This link is provided in the GenerateDetailedCostReport creation request response header.
|
||||
*
|
||||
* @summary Get the status of the specified operation. This link is provided in the GenerateDetailedCostReport creation request response header.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportOperationStatusBySubscriptionScope.json
|
||||
*/
|
||||
async function getDetailsOfTheOperationStatus() {
|
||||
const operationId = "00000000-0000-0000-0000-000000000000";
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateDetailedCostReportOperationStatus.get(operationId, scope);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
getDetailsOfTheOperationStatus();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the reservations details report for provided date range asynchronously based on enrollment id. The Reservation usage details can be viewed only by certain enterprise roles. For more details on the roles see, https://docs.microsoft.com/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role
|
||||
*
|
||||
* @summary Generates the reservations details report for provided date range asynchronously based on enrollment id. The Reservation usage details can be viewed only by certain enterprise roles. For more details on the roles see, https://docs.microsoft.com/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateReservationDetailsReportByBillingAccount.json
|
||||
*/
|
||||
async function reservationDetails() {
|
||||
const billingAccountId = "9845612";
|
||||
const startDate = "2020-01-01";
|
||||
const endDate = "2020-01-30";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateReservationDetailsReport.beginByBillingAccountIdAndWait(
|
||||
billingAccountId,
|
||||
startDate,
|
||||
endDate
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
reservationDetails();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Generates the reservations details report for provided date range asynchronously by billing profile. The Reservation usage details can be viewed by only certain enterprise roles by default. For more details on the roles see, https://docs.microsoft.com/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access
|
||||
*
|
||||
* @summary Generates the reservations details report for provided date range asynchronously by billing profile. The Reservation usage details can be viewed by only certain enterprise roles by default. For more details on the roles see, https://docs.microsoft.com/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateReservationDetailsReportByBillingProfile.json
|
||||
*/
|
||||
async function reservationDetails() {
|
||||
const billingAccountId = "00000000-0000-0000-0000-000000000000";
|
||||
const billingProfileId = "CZSFR-SDFXC-DSDF";
|
||||
const startDate = "2020-01-01";
|
||||
const endDate = "2020-01-30";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.generateReservationDetailsReport.beginByBillingProfileIdAndWait(
|
||||
billingAccountId,
|
||||
billingProfileId,
|
||||
startDate,
|
||||
endDate
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
reservationDetails();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Lists all of the available cost management REST API operations.
|
||||
*
|
||||
* @summary Lists all of the available cost management REST API operations.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/OperationList.json
|
||||
*/
|
||||
async function operationList() {
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const resArray = new Array();
|
||||
for await (let item of client.operations.list()) {
|
||||
resArray.push(item);
|
||||
}
|
||||
console.log(resArray);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
operationList();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "@azure-samples/arm-costmanagement-js-beta",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"description": " client library samples for JavaScript (Beta)",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Azure/azure-sdk-for-js.git",
|
||||
"directory": "sdk/cost-management/arm-costmanagement"
|
||||
},
|
||||
"keywords": [
|
||||
"node",
|
||||
"azure",
|
||||
"typescript",
|
||||
"browser",
|
||||
"isomorphic"
|
||||
],
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cost-management/arm-costmanagement",
|
||||
"dependencies": {
|
||||
"@azure/arm-costmanagement": "next",
|
||||
"dotenv": "latest",
|
||||
"@azure/identity": "^2.0.1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets a URL to download the current month's pricesheet for a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to Azure product growth, the Azure price sheet download experience in this preview version will be updated from a single csv file to a Zip file containing multiple csv files, each with max 200k records.
|
||||
*
|
||||
* @summary Gets a URL to download the current month's pricesheet for a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.Due to Azure product growth, the Azure price sheet download experience in this preview version will be updated from a single csv file to a Zip file containing multiple csv files, each with max 200k records.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PricesheetDownloadByBillingProfile.json
|
||||
*/
|
||||
async function pricesheetDownloadByBillingProfile() {
|
||||
const billingAccountName =
|
||||
"7c05a543-80ff-571e-9f98-1063b3b53cf2:99ad03ad-2d1b-4889-a452-090ad407d25f_2019-05-31";
|
||||
const billingProfileName = "2USN-TPCD-BG7-TGB";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.priceSheet.beginDownloadByBillingProfileAndWait(
|
||||
billingAccountName,
|
||||
billingProfileName
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
pricesheetDownloadByBillingProfile();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Gets a URL to download the pricesheet for an invoice. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
|
||||
*
|
||||
* @summary Gets a URL to download the pricesheet for an invoice. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PricesheetDownload.json
|
||||
*/
|
||||
async function pricesheetDownload() {
|
||||
const billingAccountName =
|
||||
"7c05a543-80ff-571e-9f98-1063b3b53cf2:99ad03ad-2d1b-4889-a452-090ad407d25f_2019-05-31";
|
||||
const billingProfileName = "2USN-TPCD-BG7-TGB";
|
||||
const invoiceName = "T000940677";
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.priceSheet.beginDownloadAndWait(
|
||||
billingAccountName,
|
||||
billingProfileName,
|
||||
invoiceName
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
pricesheetDownload();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for external cloud provider type defined.
|
||||
*
|
||||
* @summary Query the usage data for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountsQuery.json
|
||||
*/
|
||||
async function externalBillingAccountQueryList() {
|
||||
const externalCloudProviderType = "externalBillingAccounts";
|
||||
const externalCloudProviderId = "100";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usageByExternalCloudProviderType(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for external cloud provider type defined.
|
||||
*
|
||||
* @summary Query the usage data for external cloud provider type defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionsQuery.json
|
||||
*/
|
||||
async function externalSubscriptionsQuery() {
|
||||
const externalCloudProviderType = "externalSubscriptions";
|
||||
const externalCloudProviderId = "100";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usageByExternalCloudProviderType(
|
||||
externalCloudProviderType,
|
||||
externalCloudProviderId,
|
||||
parameters
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
externalBillingAccountQueryList();
|
||||
externalSubscriptionsQuery();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,772 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountQuery.json
|
||||
*/
|
||||
async function billingAccountQueryLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/70664866";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountQuery.json
|
||||
*/
|
||||
async function billingAccountQueryMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountQueryGrouping.json
|
||||
*/
|
||||
async function billingAccountQueryGroupingLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/70664866";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }],
|
||||
},
|
||||
timeframe: "TheLastMonth",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountQueryGrouping.json
|
||||
*/
|
||||
async function billingAccountQueryGroupingMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }],
|
||||
},
|
||||
timeframe: "TheLastMonth",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileQuery.json
|
||||
*/
|
||||
async function billingProfileQueryMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileQueryGrouping.json
|
||||
*/
|
||||
async function billingProfileQueryGroupingMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }],
|
||||
},
|
||||
timeframe: "TheLastMonth",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerQuery.json
|
||||
*/
|
||||
async function customerQueryMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerQueryGrouping.json
|
||||
*/
|
||||
async function customerQueryGroupingMca() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }],
|
||||
},
|
||||
timeframe: "TheLastMonth",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentQuery.json
|
||||
*/
|
||||
async function departmentQueryLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/departments/123";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentQueryGrouping.json
|
||||
*/
|
||||
async function departmentQueryGroupingLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/departments/123";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }],
|
||||
},
|
||||
timeframe: "TheLastMonth",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountQuery.json
|
||||
*/
|
||||
async function enrollmentAccountQueryLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountQueryGrouping.json
|
||||
*/
|
||||
async function enrollmentAccountQueryGroupingLegacy() {
|
||||
const scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "Daily",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }],
|
||||
},
|
||||
timeframe: "TheLastMonth",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionQuery.json
|
||||
*/
|
||||
async function invoiceSectionQueryMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionQueryGrouping.json
|
||||
*/
|
||||
async function invoiceSectionQueryGroupingMca() {
|
||||
const scope =
|
||||
"providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }],
|
||||
},
|
||||
timeframe: "TheLastMonth",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupQuery.json
|
||||
*/
|
||||
async function managementGroupQueryLegacy() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/MyMgId";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupQueryGrouping.json
|
||||
*/
|
||||
async function managementGroupQueryGroupingLegacy() {
|
||||
const scope = "providers/Microsoft.Management/managementGroups/MyMgId";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }],
|
||||
},
|
||||
timeframe: "TheLastMonth",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupQuery.json
|
||||
*/
|
||||
async function resourceGroupQueryLegacy() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupQueryGrouping.json
|
||||
*/
|
||||
async function resourceGroupQueryGroupingLegacy() {
|
||||
const scope =
|
||||
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "Daily",
|
||||
grouping: [{ name: "ResourceType", type: "Dimension" }],
|
||||
},
|
||||
timeframe: "TheLastMonth",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionQuery.json
|
||||
*/
|
||||
async function subscriptionQueryLegacy() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
or: [
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceLocation",
|
||||
operator: "In",
|
||||
values: ["East US", "West Europe"],
|
||||
},
|
||||
},
|
||||
{
|
||||
tags: {
|
||||
name: "Environment",
|
||||
operator: "In",
|
||||
values: ["UAT", "Prod"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
dimensions: {
|
||||
name: "ResourceGroup",
|
||||
operator: "In",
|
||||
values: ["API"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
granularity: "Daily",
|
||||
},
|
||||
timeframe: "MonthToDate",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Query the usage data for scope defined.
|
||||
*
|
||||
* @summary Query the usage data for scope defined.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionQueryGrouping.json
|
||||
*/
|
||||
async function subscriptionQueryGroupingLegacy() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const parameters = {
|
||||
type: "Usage",
|
||||
dataset: {
|
||||
aggregation: { totalCost: { name: "PreTaxCost", function: "Sum" } },
|
||||
granularity: "None",
|
||||
grouping: [{ name: "ResourceGroup", type: "Dimension" }],
|
||||
},
|
||||
timeframe: "TheLastMonth",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.query.usage(scope, parameters);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
billingAccountQueryLegacy();
|
||||
billingAccountQueryMca();
|
||||
billingAccountQueryGroupingLegacy();
|
||||
billingAccountQueryGroupingMca();
|
||||
billingProfileQueryMca();
|
||||
billingProfileQueryGroupingMca();
|
||||
customerQueryMca();
|
||||
customerQueryGroupingMca();
|
||||
departmentQueryLegacy();
|
||||
departmentQueryGroupingLegacy();
|
||||
enrollmentAccountQueryLegacy();
|
||||
enrollmentAccountQueryGroupingLegacy();
|
||||
invoiceSectionQueryMca();
|
||||
invoiceSectionQueryGroupingMca();
|
||||
managementGroupQueryLegacy();
|
||||
managementGroupQueryGroupingLegacy();
|
||||
resourceGroupQueryLegacy();
|
||||
resourceGroupQueryGroupingLegacy();
|
||||
subscriptionQueryLegacy();
|
||||
subscriptionQueryGroupingLegacy();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,4 @@
|
|||
# App registration secret for AAD authentication
|
||||
AZURE_CLIENT_SECRET=
|
||||
AZURE_CLIENT_ID=
|
||||
AZURE_TENANT_ID=
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Checks availability and correctness of the name for a scheduled action within the given scope.
|
||||
*
|
||||
* @summary Checks availability and correctness of the name for a scheduled action within the given scope.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/checkNameAvailability-shared-scheduledAction.json
|
||||
*/
|
||||
async function scheduledActionCheckNameAvailabilityByScope() {
|
||||
const scope = "subscriptions/00000000-0000-0000-0000-000000000000";
|
||||
const checkNameAvailabilityRequest = {
|
||||
name: "testName",
|
||||
type: "Microsoft.CostManagement/ScheduledActions",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.checkNameAvailabilityByScope(
|
||||
scope,
|
||||
checkNameAvailabilityRequest
|
||||
);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
scheduledActionCheckNameAvailabilityByScope();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
const { CostManagementClient } = require("@azure/arm-costmanagement");
|
||||
const { DefaultAzureCredential } = require("@azure/identity");
|
||||
require("dotenv").config();
|
||||
|
||||
/**
|
||||
* This sample demonstrates how to Checks availability and correctness of the name for a scheduled action.
|
||||
*
|
||||
* @summary Checks availability and correctness of the name for a scheduled action.
|
||||
* x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/checkNameAvailability-private-scheduledAction.json
|
||||
*/
|
||||
async function scheduledActionCheckNameAvailability() {
|
||||
const checkNameAvailabilityRequest = {
|
||||
name: "testName",
|
||||
type: "Microsoft.CostManagement/ScheduledActions",
|
||||
};
|
||||
const credential = new DefaultAzureCredential();
|
||||
const client = new CostManagementClient(credential);
|
||||
const result = await client.scheduledActions.checkNameAvailability(checkNameAvailabilityRequest);
|
||||
console.log(result);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
scheduledActionCheckNameAvailability();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче