Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function quickstart() {
const credentials = await msRestNodeAuth.loginWithServicePrincipalSecret (service_principal_application_id, service_principal_secret, tenant_id);
const client = new Arm.CognitiveServicesManagementClient (credentials, subscription_id);
// Note Azure resources are also sometimes referred to as accounts.
const accounts_client = new Arm.Accounts (client);
const resource_skus_client = new Arm.ResourceSkus (client);
//
//
// Uncomment this to list all available resource kinds, SKUs, and locations for your Azure account.
list_available_kinds_skus_locations (resource_skus_client);
// Create a resource with kind Text Translation, SKU F0 (free tier), location global.
await create_resource (accounts_client, "test_resource", "TextTranslation", "F0", "Global");
// Uncomment this to list all resources for your Azure account.
list_resources (accounts_client);
clientID = process.env["ARM_CLIENT_ID"];
clientSecret = process.env["ARM_CLIENT_SECRET"];
tenantID = process.env["ARM_TENANT_ID"];
subscriptionID = process.env["ARM_SUBSCRIPTION_ID"];
}
// If they are still empty, try to get the creds from Az CLI.
if (!clientID || !clientSecret || !tenantID || !subscriptionID) {
await pulumi.log.info("Env vars did not contain ARM credentials. Trying Az CLI.", undefined, undefined, true);
// `create()` will throw an error if the Az CLI is not installed or `az login` has never been run.
const cliCredentials = await msRestAzure.AzureCliCredentials.create();
subscriptionID = cliCredentials.subscriptionInfo.id;
credentials = cliCredentials;
await pulumi.log.info("Using credentials from Az CLI.", undefined, undefined, true);
} else {
credentials = await msRestAzure.loginWithServicePrincipalSecret(clientID, clientSecret, tenantID);
}
return new cdnManagement.CdnManagementClient(credentials, subscriptionID);
}
async function main(): Promise {
const clientId = process.env["CLIENT_ID"] || "";
const clientSecret = process.env["CLIENT_SECRET"] || "";
const tenantId = process.env["TENANT_ID"] || "";
const vaultName = process.env["KEYVAULT_NAME"] || ""
const url = `https://${vaultName}.vault.azure.net`;
// Authenticate with Azure AD interactively
// const authResponse = await msRestNodeAuth.interactiveLoginWithAuthResponse({
// tokenAudience: 'https://vault.azure.net'
// });
// Or authenticate with Azure AD using MSI to get TokenCredential.
const credential = await msRestNodeAuth.loginWithServicePrincipalSecret(
clientId,
clientSecret,
tenantId,
{
tokenAudience: 'https://vault.azure.net'
}
);
const client = new SecretsClient(url, credential);
// The client can be configured using NewPipelineOptions
// const client = new SecretsClient(url, credential, {
// telemetry: { value: "Customized-user-agent/0.1"},
// retryOptions: { retryCount: 5 }
// });
async function main(): Promise {
const credentials = await loginWithServicePrincipalSecret(clientId, secret, domain, { tokenAudience: aadEventHubsAudience });
const client = EventHubClient.createFromAadTokenCredentials(address, path, credentials);
const partitionIds = await client.getPartitionIds();
await client.send({ body: "Hello awesome world!!" }, partitionIds[0]);
const result: EventData[] = await client.receiveBatch(partitionIds[0], 2, 5, { eventPosition: EventPosition.fromEnqueuedTime(Date.now()) });
let i = 0;
for (const data of result) {
console.log("### Actual message (%d):", ++i, data.body);
}
await client.close();
}
async function main() {
const tokenCreds = await loginWithServicePrincipalSecret(clientId, clientSecret, tenantId, {
tokenAudience: "https://servicebus.azure.net/"
});
const sbClient = ServiceBusClient.createFromAadTokenCredentials(serviceBusEndpoint, tokenCreds);
/*
Refer to other samples, and place your code here
to create queue clients, and send/receive messages
*/
await sbClient.close();
}
export async function login(): Promise {
const creds = await msRestNodeAuth.loginWithServicePrincipalSecret(clientId, secret, tenant)
const websites = new appservice.WebSiteManagementClient(creds as any, subscriptionId)
return {
websites,
webapps: new appservice.WebApps(websites),
secrets: new SecretClient(`https://majavashakki-vault.vault.azure.net`, new EnvironmentCredential()),
cosmosdb: new cosmosdb.CosmosDBManagementClient(creds as any, subscriptionId),
containerregistry: new ContainerRegistryManagementClient(creds as any, subscriptionId),
}
}
async function main(): Promise {
const tokenCreds = await loginWithServicePrincipalSecret(clientId, clientSecret, tenantId, {
tokenAudience: "https://servicebus.azure.net/"
});
const sbClient = ServiceBusClient.createFromAadTokenCredentials(serviceBusEndpoint, tokenCreds);
/*
Refer to other samples, and place your code here
to create queue clients, and send/receive messages
*/
await sbClient.close();
}