Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function createResourceGroup(
name: string,
subscription: string,
creds: DeviceTokenCredentials,
location: string
): Promise {
// TODO: throws an error here if the subscription is wrong
const client = new ResourceManagementClient(creds, subscription);
const resourceGroupRes = await client.resourceGroups.createOrUpdate(name, {
location
});
return resourceGroupRes;
}
public constructor(serverless: Serverless, options: ServerlessAzureOptions) {
super(serverless, options);
this.resourceClient = new ResourceManagementClient(this.credentials, this.subscriptionId);
}
public async get_update_domain_count(): Promise {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let client = new ResourceManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let availResource = await client.resources.get(await util.resource_group(), "Microsoft.Compute", "", "availabilitySets", name, "2018-06-01");
return availResource.properties.platformUpdateDomainCount;
}
}
export async function getResourceGroups(creds: DeviceTokenCredentials, subscription: string) {
const client = new ResourceManagementClient(creds, subscription);
const resourceGroupList = (await client.resourceGroups.list()) as ResourceGroupDetails[];
return resourceGroupList;
}
public constructor(serverless: Serverless, options: Serverless.Options) {
super(serverless, options);
this.resourceClient = new ResourceManagementClient(this.credentials, this.subscriptionId);
}
constructor(clientId, clientSecret, tenantId, subscriptionId) {
this.clientId = clientId;
this.clientSecret = clientSecret;
this.tenantId = tenantId;
this.subscriptionId = subscriptionId;
this.classList = new Map();
this.classList.set('WebSiteManagementClient', WebSiteManagementClient);
this.classList.set('ResourceManagementClient', ResourceManagementClient);
this.classList.set('StorageManagementClient', StorageManagementClient);
this.classList.set('ApiManagementClient', ApiManagementClient);
this.classList.set('CdnManagementClient', CdnManagementClient);
this.classList.set('CosmosDBManagementClient', CosmosDBManagementClient);
this.classList.set('EventHubManagementClient', EventHubManagementClient);
this.classList.set('ServiceBusManagementClient', ServiceBusManagementClient);
this.instanceList = new Map();
}
public async get_fault_domain_count(): Promise {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
let client = new ResourceManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let availResource = await client.resources.get(await util.resource_group(), "Microsoft.Compute", "", "availabilitySets", name, "2018-06-01");
return availResource.properties.platformFaultDomainCount;
}
const azureResources = async ({userConfig, answer, configTmpl}) => {
userConfig.auth = userConfig.auth || {};
if (!userConfig.auth.azure_account_key || !userConfig.queue.azure_account_key) {
const resourceGroupName = answer.azureAccountId || userConfig.azureAccountId;
const location = (answer.meta || {}).azureRegion || (userConfig.meta || {}).azureRegion;
const creds = await msRestNodeAuth.interactiveLogin();
const subscriptionId = answer.meta.azureSubscriptionId || userConfig.meta.azureSubscriptionId;
const resourceClient = new ResourceManagementClient(creds, subscriptionId);
await resourceClient.resourceGroups.createOrUpdate(resourceGroupName, {
location,
tags: {},
});
const storageClient = new StorageManagementClient(creds, subscriptionId);
await storageClient.storageAccounts.create(
resourceGroupName,
resourceGroupName,
{
sku: {
name: 'Standard_RAGRS',
},
kind: 'Storage',
location,