forked from Azure/azure-sdk-for-js
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add samples for appcontainers (Azure#26000)
- Loading branch information
1 parent
d79860f
commit a05ad75
Showing
197 changed files
with
10,131 additions
and
0 deletions.
There are no files selected for viewing
238 changes: 238 additions & 0 deletions
238
sdk/appcontainers/arm-appcontainers/samples/v2-beta/javascript/README.md
Large diffs are not rendered by default.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
...ainers/arm-appcontainers/samples/v2-beta/javascript/availableWorkloadProfilesGetSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { ContainerAppsAPIClient } = require("@azure/arm-appcontainers"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
require("dotenv").config(); | ||
|
||
/** | ||
* This sample demonstrates how to Get all available workload profiles for a location. | ||
* | ||
* @summary Get all available workload profiles for a location. | ||
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/AvailableWorkloadProfiles_Get.json | ||
*/ | ||
async function billingMetersGet() { | ||
const subscriptionId = | ||
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; | ||
const location = "East US"; | ||
const credential = new DefaultAzureCredential(); | ||
const client = new ContainerAppsAPIClient(credential, subscriptionId); | ||
const resArray = new Array(); | ||
for await (let item of client.availableWorkloadProfiles.list(location)) { | ||
resArray.push(item); | ||
} | ||
console.log(resArray); | ||
} | ||
|
||
async function main() { | ||
billingMetersGet(); | ||
} | ||
|
||
main().catch(console.error); |
35 changes: 35 additions & 0 deletions
35
sdk/appcontainers/arm-appcontainers/samples/v2-beta/javascript/billingMetersGetSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { ContainerAppsAPIClient } = require("@azure/arm-appcontainers"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
require("dotenv").config(); | ||
|
||
/** | ||
* This sample demonstrates how to Get all billingMeters for a location. | ||
* | ||
* @summary Get all billingMeters for a location. | ||
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/BillingMeters_Get.json | ||
*/ | ||
async function billingMetersGet() { | ||
const subscriptionId = | ||
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; | ||
const location = "East US"; | ||
const credential = new DefaultAzureCredential(); | ||
const client = new ContainerAppsAPIClient(credential, subscriptionId); | ||
const result = await client.billingMeters.get(location); | ||
console.log(result); | ||
} | ||
|
||
async function main() { | ||
billingMetersGet(); | ||
} | ||
|
||
main().catch(console.error); |
52 changes: 52 additions & 0 deletions
52
...ntainers/arm-appcontainers/samples/v2-beta/javascript/certificatesCreateOrUpdateSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
require("dotenv").config(); | ||
|
||
/** | ||
* This sample demonstrates how to Create or Update a Certificate. | ||
* | ||
* @summary Create or Update a Certificate. | ||
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/Certificate_CreateOrUpdate.json | ||
*/ | ||
async function createOrUpdateCertificate() { | ||
const subscriptionId = | ||
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; | ||
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg"; | ||
const environmentName = "testcontainerenv"; | ||
const certificateName = "certificate-firendly-name"; | ||
const certificateEnvelope = { | ||
location: "East US", | ||
properties: { | ||
password: "private key password", | ||
value: Buffer.from("Y2VydA=="), | ||
}, | ||
}; | ||
const options = { | ||
certificateEnvelope, | ||
}; | ||
const credential = new DefaultAzureCredential(); | ||
const client = new ContainerAppsAPIClient(credential, subscriptionId); | ||
const result = await client.certificates.createOrUpdate( | ||
resourceGroupName, | ||
environmentName, | ||
certificateName, | ||
options | ||
); | ||
console.log(result); | ||
} | ||
|
||
async function main() { | ||
createOrUpdateCertificate(); | ||
} | ||
|
||
main().catch(console.error); |
41 changes: 41 additions & 0 deletions
41
sdk/appcontainers/arm-appcontainers/samples/v2-beta/javascript/certificatesDeleteSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { ContainerAppsAPIClient } = require("@azure/arm-appcontainers"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
require("dotenv").config(); | ||
|
||
/** | ||
* This sample demonstrates how to Deletes the specified Certificate. | ||
* | ||
* @summary Deletes the specified Certificate. | ||
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/Certificate_Delete.json | ||
*/ | ||
async function deleteCertificate() { | ||
const subscriptionId = | ||
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; | ||
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg"; | ||
const environmentName = "testcontainerenv"; | ||
const certificateName = "certificate-firendly-name"; | ||
const credential = new DefaultAzureCredential(); | ||
const client = new ContainerAppsAPIClient(credential, subscriptionId); | ||
const result = await client.certificates.delete( | ||
resourceGroupName, | ||
environmentName, | ||
certificateName | ||
); | ||
console.log(result); | ||
} | ||
|
||
async function main() { | ||
deleteCertificate(); | ||
} | ||
|
||
main().catch(console.error); |
37 changes: 37 additions & 0 deletions
37
sdk/appcontainers/arm-appcontainers/samples/v2-beta/javascript/certificatesGetSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { ContainerAppsAPIClient } = require("@azure/arm-appcontainers"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
require("dotenv").config(); | ||
|
||
/** | ||
* This sample demonstrates how to Get the specified Certificate. | ||
* | ||
* @summary Get the specified Certificate. | ||
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/Certificate_Get.json | ||
*/ | ||
async function getCertificate() { | ||
const subscriptionId = | ||
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; | ||
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg"; | ||
const environmentName = "testcontainerenv"; | ||
const certificateName = "certificate-firendly-name"; | ||
const credential = new DefaultAzureCredential(); | ||
const client = new ContainerAppsAPIClient(credential, subscriptionId); | ||
const result = await client.certificates.get(resourceGroupName, environmentName, certificateName); | ||
console.log(result); | ||
} | ||
|
||
async function main() { | ||
getCertificate(); | ||
} | ||
|
||
main().catch(console.error); |
39 changes: 39 additions & 0 deletions
39
sdk/appcontainers/arm-appcontainers/samples/v2-beta/javascript/certificatesListSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { ContainerAppsAPIClient } = require("@azure/arm-appcontainers"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
require("dotenv").config(); | ||
|
||
/** | ||
* This sample demonstrates how to Get the Certificates in a given managed environment. | ||
* | ||
* @summary Get the Certificates in a given managed environment. | ||
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/Certificates_ListByManagedEnvironment.json | ||
*/ | ||
async function listCertificatesByManagedEnvironment() { | ||
const subscriptionId = | ||
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; | ||
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg"; | ||
const environmentName = "testcontainerenv"; | ||
const credential = new DefaultAzureCredential(); | ||
const client = new ContainerAppsAPIClient(credential, subscriptionId); | ||
const resArray = new Array(); | ||
for await (let item of client.certificates.list(resourceGroupName, environmentName)) { | ||
resArray.push(item); | ||
} | ||
console.log(resArray); | ||
} | ||
|
||
async function main() { | ||
listCertificatesByManagedEnvironment(); | ||
} | ||
|
||
main().catch(console.error); |
45 changes: 45 additions & 0 deletions
45
sdk/appcontainers/arm-appcontainers/samples/v2-beta/javascript/certificatesUpdateSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
require("dotenv").config(); | ||
|
||
/** | ||
* This sample demonstrates how to Patches a certificate. Currently only patching of tags is supported | ||
* | ||
* @summary Patches a certificate. Currently only patching of tags is supported | ||
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/Certificates_Patch.json | ||
*/ | ||
async function patchCertificate() { | ||
const subscriptionId = | ||
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; | ||
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg"; | ||
const environmentName = "testcontainerenv"; | ||
const certificateName = "certificate-firendly-name"; | ||
const certificateEnvelope = { | ||
tags: { tag1: "value1", tag2: "value2" }, | ||
}; | ||
const credential = new DefaultAzureCredential(); | ||
const client = new ContainerAppsAPIClient(credential, subscriptionId); | ||
const result = await client.certificates.update( | ||
resourceGroupName, | ||
environmentName, | ||
certificateName, | ||
certificateEnvelope | ||
); | ||
console.log(result); | ||
} | ||
|
||
async function main() { | ||
patchCertificate(); | ||
} | ||
|
||
main().catch(console.error); |
52 changes: 52 additions & 0 deletions
52
...iners/samples/v2-beta/javascript/connectedEnvironmentsCertificatesCreateOrUpdateSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
require("dotenv").config(); | ||
|
||
/** | ||
* This sample demonstrates how to Create or Update a Certificate. | ||
* | ||
* @summary Create or Update a Certificate. | ||
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/ConnectedEnvironmentsCertificate_CreateOrUpdate.json | ||
*/ | ||
async function createOrUpdateCertificate() { | ||
const subscriptionId = | ||
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; | ||
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg"; | ||
const connectedEnvironmentName = "testcontainerenv"; | ||
const certificateName = "certificate-firendly-name"; | ||
const certificateEnvelope = { | ||
location: "East US", | ||
properties: { | ||
password: "private key password", | ||
value: Buffer.from("Y2VydA=="), | ||
}, | ||
}; | ||
const options = { | ||
certificateEnvelope, | ||
}; | ||
const credential = new DefaultAzureCredential(); | ||
const client = new ContainerAppsAPIClient(credential, subscriptionId); | ||
const result = await client.connectedEnvironmentsCertificates.createOrUpdate( | ||
resourceGroupName, | ||
connectedEnvironmentName, | ||
certificateName, | ||
options | ||
); | ||
console.log(result); | ||
} | ||
|
||
async function main() { | ||
createOrUpdateCertificate(); | ||
} | ||
|
||
main().catch(console.error); |
41 changes: 41 additions & 0 deletions
41
...appcontainers/samples/v2-beta/javascript/connectedEnvironmentsCertificatesDeleteSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { ContainerAppsAPIClient } = require("@azure/arm-appcontainers"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
require("dotenv").config(); | ||
|
||
/** | ||
* This sample demonstrates how to Deletes the specified Certificate. | ||
* | ||
* @summary Deletes the specified Certificate. | ||
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/ConnectedEnvironmentsCertificate_Delete.json | ||
*/ | ||
async function deleteCertificate() { | ||
const subscriptionId = | ||
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; | ||
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg"; | ||
const connectedEnvironmentName = "testcontainerenv"; | ||
const certificateName = "certificate-firendly-name"; | ||
const credential = new DefaultAzureCredential(); | ||
const client = new ContainerAppsAPIClient(credential, subscriptionId); | ||
const result = await client.connectedEnvironmentsCertificates.delete( | ||
resourceGroupName, | ||
connectedEnvironmentName, | ||
certificateName | ||
); | ||
console.log(result); | ||
} | ||
|
||
async function main() { | ||
deleteCertificate(); | ||
} | ||
|
||
main().catch(console.error); |
Oops, something went wrong.