Skip to content

Commit a05ad75

Browse files
authored
add samples for appcontainers (Azure#26000)
1 parent d79860f commit a05ad75

File tree

197 files changed

+10131
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+10131
-0
lines changed

sdk/appcontainers/arm-appcontainers/samples/v2-beta/javascript/README.md

Lines changed: 238 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
*/
8+
9+
// Copyright (c) Microsoft Corporation.
10+
// Licensed under the MIT License.
11+
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
12+
const { DefaultAzureCredential } = require("@azure/identity");
13+
require("dotenv").config();
14+
15+
/**
16+
* This sample demonstrates how to Get all available workload profiles for a location.
17+
*
18+
* @summary Get all available workload profiles for a location.
19+
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/AvailableWorkloadProfiles_Get.json
20+
*/
21+
async function billingMetersGet() {
22+
const subscriptionId =
23+
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
24+
const location = "East US";
25+
const credential = new DefaultAzureCredential();
26+
const client = new ContainerAppsAPIClient(credential, subscriptionId);
27+
const resArray = new Array();
28+
for await (let item of client.availableWorkloadProfiles.list(location)) {
29+
resArray.push(item);
30+
}
31+
console.log(resArray);
32+
}
33+
34+
async function main() {
35+
billingMetersGet();
36+
}
37+
38+
main().catch(console.error);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
*/
8+
9+
// Copyright (c) Microsoft Corporation.
10+
// Licensed under the MIT License.
11+
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
12+
const { DefaultAzureCredential } = require("@azure/identity");
13+
require("dotenv").config();
14+
15+
/**
16+
* This sample demonstrates how to Get all billingMeters for a location.
17+
*
18+
* @summary Get all billingMeters for a location.
19+
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/BillingMeters_Get.json
20+
*/
21+
async function billingMetersGet() {
22+
const subscriptionId =
23+
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
24+
const location = "East US";
25+
const credential = new DefaultAzureCredential();
26+
const client = new ContainerAppsAPIClient(credential, subscriptionId);
27+
const result = await client.billingMeters.get(location);
28+
console.log(result);
29+
}
30+
31+
async function main() {
32+
billingMetersGet();
33+
}
34+
35+
main().catch(console.error);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
*/
8+
9+
// Copyright (c) Microsoft Corporation.
10+
// Licensed under the MIT License.
11+
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
12+
const { DefaultAzureCredential } = require("@azure/identity");
13+
require("dotenv").config();
14+
15+
/**
16+
* This sample demonstrates how to Create or Update a Certificate.
17+
*
18+
* @summary Create or Update a Certificate.
19+
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/Certificate_CreateOrUpdate.json
20+
*/
21+
async function createOrUpdateCertificate() {
22+
const subscriptionId =
23+
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
24+
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg";
25+
const environmentName = "testcontainerenv";
26+
const certificateName = "certificate-firendly-name";
27+
const certificateEnvelope = {
28+
location: "East US",
29+
properties: {
30+
password: "private key password",
31+
value: Buffer.from("Y2VydA=="),
32+
},
33+
};
34+
const options = {
35+
certificateEnvelope,
36+
};
37+
const credential = new DefaultAzureCredential();
38+
const client = new ContainerAppsAPIClient(credential, subscriptionId);
39+
const result = await client.certificates.createOrUpdate(
40+
resourceGroupName,
41+
environmentName,
42+
certificateName,
43+
options
44+
);
45+
console.log(result);
46+
}
47+
48+
async function main() {
49+
createOrUpdateCertificate();
50+
}
51+
52+
main().catch(console.error);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
*/
8+
9+
// Copyright (c) Microsoft Corporation.
10+
// Licensed under the MIT License.
11+
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
12+
const { DefaultAzureCredential } = require("@azure/identity");
13+
require("dotenv").config();
14+
15+
/**
16+
* This sample demonstrates how to Deletes the specified Certificate.
17+
*
18+
* @summary Deletes the specified Certificate.
19+
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/Certificate_Delete.json
20+
*/
21+
async function deleteCertificate() {
22+
const subscriptionId =
23+
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
24+
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg";
25+
const environmentName = "testcontainerenv";
26+
const certificateName = "certificate-firendly-name";
27+
const credential = new DefaultAzureCredential();
28+
const client = new ContainerAppsAPIClient(credential, subscriptionId);
29+
const result = await client.certificates.delete(
30+
resourceGroupName,
31+
environmentName,
32+
certificateName
33+
);
34+
console.log(result);
35+
}
36+
37+
async function main() {
38+
deleteCertificate();
39+
}
40+
41+
main().catch(console.error);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
*/
8+
9+
// Copyright (c) Microsoft Corporation.
10+
// Licensed under the MIT License.
11+
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
12+
const { DefaultAzureCredential } = require("@azure/identity");
13+
require("dotenv").config();
14+
15+
/**
16+
* This sample demonstrates how to Get the specified Certificate.
17+
*
18+
* @summary Get the specified Certificate.
19+
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/Certificate_Get.json
20+
*/
21+
async function getCertificate() {
22+
const subscriptionId =
23+
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
24+
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg";
25+
const environmentName = "testcontainerenv";
26+
const certificateName = "certificate-firendly-name";
27+
const credential = new DefaultAzureCredential();
28+
const client = new ContainerAppsAPIClient(credential, subscriptionId);
29+
const result = await client.certificates.get(resourceGroupName, environmentName, certificateName);
30+
console.log(result);
31+
}
32+
33+
async function main() {
34+
getCertificate();
35+
}
36+
37+
main().catch(console.error);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
*/
8+
9+
// Copyright (c) Microsoft Corporation.
10+
// Licensed under the MIT License.
11+
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
12+
const { DefaultAzureCredential } = require("@azure/identity");
13+
require("dotenv").config();
14+
15+
/**
16+
* This sample demonstrates how to Get the Certificates in a given managed environment.
17+
*
18+
* @summary Get the Certificates in a given managed environment.
19+
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/Certificates_ListByManagedEnvironment.json
20+
*/
21+
async function listCertificatesByManagedEnvironment() {
22+
const subscriptionId =
23+
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
24+
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg";
25+
const environmentName = "testcontainerenv";
26+
const credential = new DefaultAzureCredential();
27+
const client = new ContainerAppsAPIClient(credential, subscriptionId);
28+
const resArray = new Array();
29+
for await (let item of client.certificates.list(resourceGroupName, environmentName)) {
30+
resArray.push(item);
31+
}
32+
console.log(resArray);
33+
}
34+
35+
async function main() {
36+
listCertificatesByManagedEnvironment();
37+
}
38+
39+
main().catch(console.error);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
*/
8+
9+
// Copyright (c) Microsoft Corporation.
10+
// Licensed under the MIT License.
11+
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
12+
const { DefaultAzureCredential } = require("@azure/identity");
13+
require("dotenv").config();
14+
15+
/**
16+
* This sample demonstrates how to Patches a certificate. Currently only patching of tags is supported
17+
*
18+
* @summary Patches a certificate. Currently only patching of tags is supported
19+
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/Certificates_Patch.json
20+
*/
21+
async function patchCertificate() {
22+
const subscriptionId =
23+
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
24+
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg";
25+
const environmentName = "testcontainerenv";
26+
const certificateName = "certificate-firendly-name";
27+
const certificateEnvelope = {
28+
tags: { tag1: "value1", tag2: "value2" },
29+
};
30+
const credential = new DefaultAzureCredential();
31+
const client = new ContainerAppsAPIClient(credential, subscriptionId);
32+
const result = await client.certificates.update(
33+
resourceGroupName,
34+
environmentName,
35+
certificateName,
36+
certificateEnvelope
37+
);
38+
console.log(result);
39+
}
40+
41+
async function main() {
42+
patchCertificate();
43+
}
44+
45+
main().catch(console.error);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
*/
8+
9+
// Copyright (c) Microsoft Corporation.
10+
// Licensed under the MIT License.
11+
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
12+
const { DefaultAzureCredential } = require("@azure/identity");
13+
require("dotenv").config();
14+
15+
/**
16+
* This sample demonstrates how to Create or Update a Certificate.
17+
*
18+
* @summary Create or Update a Certificate.
19+
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/ConnectedEnvironmentsCertificate_CreateOrUpdate.json
20+
*/
21+
async function createOrUpdateCertificate() {
22+
const subscriptionId =
23+
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
24+
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg";
25+
const connectedEnvironmentName = "testcontainerenv";
26+
const certificateName = "certificate-firendly-name";
27+
const certificateEnvelope = {
28+
location: "East US",
29+
properties: {
30+
password: "private key password",
31+
value: Buffer.from("Y2VydA=="),
32+
},
33+
};
34+
const options = {
35+
certificateEnvelope,
36+
};
37+
const credential = new DefaultAzureCredential();
38+
const client = new ContainerAppsAPIClient(credential, subscriptionId);
39+
const result = await client.connectedEnvironmentsCertificates.createOrUpdate(
40+
resourceGroupName,
41+
connectedEnvironmentName,
42+
certificateName,
43+
options
44+
);
45+
console.log(result);
46+
}
47+
48+
async function main() {
49+
createOrUpdateCertificate();
50+
}
51+
52+
main().catch(console.error);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* Code generated by Microsoft (R) AutoRest Code Generator.
6+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
*/
8+
9+
// Copyright (c) Microsoft Corporation.
10+
// Licensed under the MIT License.
11+
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
12+
const { DefaultAzureCredential } = require("@azure/identity");
13+
require("dotenv").config();
14+
15+
/**
16+
* This sample demonstrates how to Deletes the specified Certificate.
17+
*
18+
* @summary Deletes the specified Certificate.
19+
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2022-11-01-preview/examples/ConnectedEnvironmentsCertificate_Delete.json
20+
*/
21+
async function deleteCertificate() {
22+
const subscriptionId =
23+
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
24+
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg";
25+
const connectedEnvironmentName = "testcontainerenv";
26+
const certificateName = "certificate-firendly-name";
27+
const credential = new DefaultAzureCredential();
28+
const client = new ContainerAppsAPIClient(credential, subscriptionId);
29+
const result = await client.connectedEnvironmentsCertificates.delete(
30+
resourceGroupName,
31+
connectedEnvironmentName,
32+
certificateName
33+
);
34+
console.log(result);
35+
}
36+
37+
async function main() {
38+
deleteCertificate();
39+
}
40+
41+
main().catch(console.error);

0 commit comments

Comments
 (0)