Skip to content

Commit

Permalink
update samples
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremymeng committed Feb 10, 2025
1 parent 317feff commit 27f5f67
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ async function main() {
console.log(` Found key: ${setting.key}, label: ${setting.label}`);
}

////////////////////////////////////////////////////////
/////////////// Example for .byPage() ////////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// Passing marker as an argument
let iterator = client.listConfigurationSettings({ keyFilter: "sample*" }).byPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ async function main() {
console.log(`At ${revision.lastModified}, the value was ${revision.value}`);
}

////////////////////////////////////////////////////////
/////////////// Example for .byPage() ////////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// If you want to see the pagination
// for (let index = 0; index < 135; index++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export async function main() {
console.log(` Found key: ${setting.key}, label: ${setting.label}`);
}

////////////////////////////////////////////////////////
/////////////// Example for .byPage() ////////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// Passing marker as an argument
let iterator = client.listConfigurationSettings({ keyFilter: "sample*" }).byPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export async function main() {
console.log(`At ${revision.lastModified}, the value was ${revision.value}`);
}

////////////////////////////////////////////////////////
/////////////// Example for .byPage() ////////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// If you want to see the pagination
// for (let index = 0; index < 135; index++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ async function main() {
console.log(` Found key: ${setting.key}, label: ${setting.label}, tags: ${setting.tags}`);
}

////////////////////////////////////////////////////////
/////////////// Example for .byPage() ////////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// Passing marker as an argument
let iterator = client.listConfigurationSettings({ keyFilter: "sample*" }).byPage();
Expand All @@ -88,7 +88,7 @@ async function main() {
}
}
// Gets next marker
let marker = response.value.continuationToken;
const marker = response.value.continuationToken;
// Passing next marker as continuationToken
iterator = client.listConfigurationSettings({ keyFilter: "sample*" }).byPage({
continuationToken: marker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ async function main() {
console.log(` Found label for development: ${label.name}`);
}

////////////////////////////////////////////////////////
/////////////// Example for .byPage() ////////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// Passing marker as an argument
let iterator = client.listLabels().byPage();
Expand All @@ -74,7 +74,7 @@ async function main() {
}
}
// Gets next marker
let marker = response.value.continuationToken;
const marker = response.value.continuationToken;
// Passing next marker as continuationToken
iterator = client.listLabels().byPage({
continuationToken: marker,
Expand All @@ -90,7 +90,7 @@ async function main() {
}
}

cleanupSampleValues(["listLabelsSample"], client);
await cleanupSampleValues(["listLabelsSample"], client);
}

async function cleanupSampleValues(keys, client) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ async function main() {
console.log(`At ${revision.lastModified}, the value was ${revision.value}`);
}

////////////////////////////////////////////////////////
/////////////// Example for .byPage() ////////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// If you want to see the pagination
// for (let index = 0; index < 135; index++) {
Expand All @@ -68,7 +68,7 @@ async function main() {
}
}
// Gets next marker
let marker = response.value.continuationToken;
const marker = response.value.continuationToken;
// Passing next marker as continuationToken
iterator = client.listRevisions({ keyFilter: "keyWithRevisions-1626819906487" }).byPage({
continuationToken: marker,
Expand All @@ -84,7 +84,7 @@ async function main() {
}
}

cleanupSampleValues([originalSetting.key], client);
await cleanupSampleValues([originalSetting.key], client);
}

async function cleanupSampleValues(keys, client) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ async function main() {
console.log("Starting Alpha and Beta updates");

// Alpha is preparing to do an update - to do this properly they retrieve the setting from the server
let alphaSetting = await client.getConfigurationSetting({ key: key });
const alphaSetting = await client.getConfigurationSetting({ key: key });

// Beta would also like to do an update and will do the same thing as Alpha
let betaSetting = await client.getConfigurationSetting({ key: key });
const betaSetting = await client.getConfigurationSetting({ key: key });

console.log(`Alpha retrieves the setting and has etag ${alphaSetting.etag}`);
console.log(`Beta retrieves the setting and has etag ${betaSetting.etag}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

const appConfigTestEvent = JSON.stringify({
id: "deb8e00d-8c64-4b6e-9cab-282259c7674f",
topic:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

const { AppConfigurationClient } = require("@azure/app-configuration");
const { isSystemEvent, EventGridDeserializer } = require("@azure/eventgrid");
const { appConfigTestEvent } = require("./testData");
const { appConfigTestEvent } = require("./testData.js");

// Load the .env file if it exists
const dotenv = require("dotenv");
Expand Down Expand Up @@ -49,7 +49,7 @@ async function main() {
const events = await processEvent();

// Iterate through events and log updated key-value pairs.
events.forEach(async (eventData) => {
await events.forEach(async (eventData) => {
if (isSystemEvent("Microsoft.AppConfiguration.KeyValueModified", eventData)) {
client.updateSyncToken(eventData.data.syncToken);
const newSetting = await client.getConfigurationSetting({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
/**
* @summary Feature flags are settings that follow specific JSON schema for the value.
*/
import type { ConfigurationSetting, FeatureFlagValue } from "@azure/app-configuration";
import {
AppConfigurationClient,
ConfigurationSetting,
featureFlagContentType,
FeatureFlagValue,
parseFeatureFlag,
} from "@azure/app-configuration";
import { DefaultAzureCredential } from "@azure/identity";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export async function main() {
console.log(` Found key: ${setting.key}, label: ${setting.label}, tags: ${setting.tags}`);
}

////////////////////////////////////////////////////////
/////////////// Example for .byPage() ////////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// Passing marker as an argument
let iterator = client.listConfigurationSettings({ keyFilter: "sample*" }).byPage();
Expand All @@ -89,7 +89,7 @@ export async function main() {
}
}
// Gets next marker
let marker = response.value.continuationToken;
const marker = response.value.continuationToken;
// Passing next marker as continuationToken
iterator = client.listConfigurationSettings({ keyFilter: "sample*" }).byPage({
continuationToken: marker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export async function main() {
console.log(` Found label for development: ${label.name}`);
}

////////////////////////////////////////////////////////
/////////////// Example for .byPage() ////////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// Passing marker as an argument
let iterator = client.listLabels().byPage();
Expand All @@ -75,7 +75,7 @@ export async function main() {
}
}
// Gets next marker
let marker = response.value.continuationToken;
const marker = response.value.continuationToken;
// Passing next marker as continuationToken
iterator = client.listLabels().byPage({
continuationToken: marker,
Expand All @@ -91,7 +91,7 @@ export async function main() {
}
}

cleanupSampleValues(["listLabelsSample"], client);
await cleanupSampleValues(["listLabelsSample"], client);
}

async function cleanupSampleValues(keys: string[], client: AppConfigurationClient) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export async function main() {
console.log(`At ${revision.lastModified}, the value was ${revision.value}`);
}

////////////////////////////////////////////////////////
/////////////// Example for .byPage() ////////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// If you want to see the pagination
// for (let index = 0; index < 135; index++) {
Expand All @@ -69,7 +69,7 @@ export async function main() {
}
}
// Gets next marker
let marker = response.value.continuationToken;
const marker = response.value.continuationToken;
// Passing next marker as continuationToken
iterator = client.listRevisions({ keyFilter: "keyWithRevisions-1626819906487" }).byPage({
continuationToken: marker,
Expand All @@ -85,7 +85,7 @@ export async function main() {
}
}

cleanupSampleValues([originalSetting.key], client);
await cleanupSampleValues([originalSetting.key], client);
}

async function cleanupSampleValues(keys: string[], client: AppConfigurationClient) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export async function main() {
console.log("Starting Alpha and Beta updates");

// Alpha is preparing to do an update - to do this properly they retrieve the setting from the server
let alphaSetting = await client.getConfigurationSetting({ key: key });
const alphaSetting = await client.getConfigurationSetting({ key: key });

// Beta would also like to do an update and will do the same thing as Alpha
let betaSetting = await client.getConfigurationSetting({ key: key });
const betaSetting = await client.getConfigurationSetting({ key: key });

console.log(`Alpha retrieves the setting and has etag ${alphaSetting.etag}`);
console.log(`Beta retrieves the setting and has etag ${betaSetting.etag}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
/**
* @summary SecretReference represents a configuration setting that references as KeyVault secret.
*/
import type { SecretReferenceValue, ConfigurationSetting } from "@azure/app-configuration";
import {
AppConfigurationClient,
SecretReferenceValue,
secretReferenceContentType,
ConfigurationSetting,
parseSecretReference,
} from "@azure/app-configuration";
import { parseKeyVaultSecretIdentifier, SecretClient } from "@azure/keyvault-secrets";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

export const appConfigTestEvent: string = JSON.stringify({
id: "deb8e00d-8c64-4b6e-9cab-282259c7674f",
topic:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
*/

import { AppConfigurationClient } from "@azure/app-configuration";
import { isSystemEvent, EventGridEvent, EventGridDeserializer } from "@azure/eventgrid";
import { appConfigTestEvent } from "./testData";
import type { EventGridEvent } from "@azure/eventgrid";
import { isSystemEvent, EventGridDeserializer } from "@azure/eventgrid";
import { appConfigTestEvent } from "./testData.js";

// Load the .env file if it exists
import * as dotenv from "dotenv";
Expand Down Expand Up @@ -49,7 +50,7 @@ export async function main() {
const events = await processEvent();

// Iterate through events and log updated key-value pairs.
events.forEach(async (eventData) => {
await events.forEach(async (eventData) => {
if (isSystemEvent("Microsoft.AppConfiguration.KeyValueModified", eventData)) {
client.updateSyncToken(eventData.data.syncToken);
const newSetting = await client.getConfigurationSetting({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ES2023",
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"lib": [],
"importHelpers": true,
"strict": true,
"alwaysStrict": true,
"outDir": "dist",
"rootDir": "src"
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node10",
"esModuleInterop": true,
"outDir": "./dist",
"resolveJsonModule": true
},
"include": [
"src/**/*.ts"
"./src"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ async function main() {
queueItem = await queues.next();
}

////////////////////////////////////////////////////////
/////////////// Examples for .byPage() ///////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// 4. list queues by page
i = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export async function main() {
queueItem = await queues.next();
}

////////////////////////////////////////////////////////
/////////////// Examples for .byPage() ///////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// 4. list queues by page
i = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ async function main() {
queueItem = await queues.next();
}

////////////////////////////////////////////////////////
/////////////// Examples for .byPage() ///////////////
////////////////////////////////////////////////////////
/*
* Example for .byPage()
*/

// 4. list queues by page
i = 1;
Expand Down
Loading

0 comments on commit 27f5f67

Please sign in to comment.