Skip to content

Commit

Permalink
add samples for appcontainers (Azure#26000)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazrael2119 authored Jul 24, 2023
1 parent d79860f commit a05ad75
Show file tree
Hide file tree
Showing 197 changed files with 10,131 additions and 0 deletions.

Large diffs are not rendered by default.

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);
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);
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);
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);
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);
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);
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);
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);
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);
Loading

0 comments on commit a05ad75

Please sign in to comment.