Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async get_secondary_key(name: string, rg: string | null = null) : Promise {
let util = IngredientManager.getIngredientFunction("coreutils", this.context)
let resource_group = rg || await util.resource_group()
const client = new StorageManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.storageAccounts.listKeys(resource_group, name)
let key: string = ""
if (response.keys)
{
key = response.keys[1].value || ""
}
return key
}
public async get_primary_key(name: string, rg: string | null = null) : Promise {
let util = IngredientManager.getIngredientFunction("coreutils", this.context)
let resource_group = rg || await util.resource_group()
const client = new StorageManagementClient(this.context.AuthToken, this.context.Environment.authentication.subscriptionId);
let response = await client.storageAccounts.listKeys(resource_group, name)
let key: string = ""
if (response.keys)
{
key = response.keys[0].value || ""
}
return key
}
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();
}
export function getAzureStorageClient(credentials: DeviceTokenCredentials, subscriptionId: string) {
return new StorageManagementClient(credentials, subscriptionId);
}
}
} else if (azureHostingConfig.app.path) {
context.logger.info(`Fetching files from the path configured in azure.json: ${azureHostingConfig.app.path}`);
filesPath = path.join(projectRoot, azureHostingConfig.app.path);
}
if (!filesPath) {
throw new Error('No path is configured for the files to deploy.');
}
const files = await getFiles(context, filesPath, projectRoot);
if (files.length === 0) {
throw new Error('Target did not produce any files, or the path is incorrect.');
}
const client = new StorageManagementClient(credentials, azureHostingConfig.azureHosting.subscription);
const accountKey = await getAccountKey(
azureHostingConfig.azureHosting.account,
client,
azureHostingConfig.azureHosting.resourceGroupName
);
const pipeline = ServiceURL.newPipeline(new SharedKeyCredential(azureHostingConfig.azureHosting.account, accountKey));
const serviceURL = new ServiceURL(
`https://${azureHostingConfig.azureHosting.account}.blob.core.windows.net`,
pipeline
);
await uploadFilesToAzure(serviceURL, context, filesPath, files);
const accountProps = await client.storageAccounts.getProperties(
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,
tags: {},
},
);
const accountId = answer.azureAccountId || userConfig.azureAccountId;
const result = await storageClient.storageAccounts.listKeys(
accountId,
resourceGroupName,
public async getStorageAccountKey(subscriptionId: string, resourceGroupName: string, accountName: string, credentials: ServiceClientCredentials) {
const context = new StorageManagementClientContext(this.credentials, subscriptionId);
const storageAccounts = new StorageAccounts(context);
const accounts = await storageAccounts.list();
if (!accounts.find((account) => account.name === accountName)) {
throw new Error(`Couldn't find storage account with name ${accountName}`);
}
const { keys } = await storageAccounts.listKeys(resourceGroupName, accountName);
return keys[0].value;
}
}
private async getKey(): Promise {
const context = new StorageManagementClientContext(this.credentials, this.subscriptionId)
const storageAccounts = new StorageAccounts(context);
const keys = await storageAccounts.listKeys(this.resourceGroup, this.storageAccountName);
return keys.keys[0].value;
}
private async getKey(): Promise {
const context = new StorageManagementClientContext(this.credentials, this.subscriptionId)
const storageAccounts = new StorageAccounts(context);
const keys = await storageAccounts.listKeys(this.resourceGroup, this.storageAccountName);
return keys.keys[0].value;
}
public async getStorageAccountKey(subscriptionId: string, resourceGroupName: string, accountName: string, credentials: ServiceClientCredentials) {
const context = new StorageManagementClientContext(this.credentials, subscriptionId);
const storageAccounts = new StorageAccounts(context);
const accounts = await storageAccounts.list();
if (!accounts.find((account) => account.name === accountName)) {
throw new Error(`Couldn't find storage account with name ${accountName}`);
}
const { keys } = await storageAccounts.listKeys(resourceGroupName, accountName);
return keys[0].value;
}
}