How to use @azure/arm-storage - 10 common examples

To help you get started, we’ve selected a few @azure/arm-storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HomecareHomebase / azure-bake / ingredient / ingredient-storage / src / functions.ts View on Github external
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
    }
github HomecareHomebase / azure-bake / ingredient / ingredient-storage / src / functions.ts View on Github external
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
    }
github tmobile / jazz / builds / jazz_azure-create-service / components / ClientFactory.js View on Github external
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();
    }
github Azure / ng-deploy-azure / src / util / azure / account.ts View on Github external
export function getAzureStorageClient(credentials: DeviceTokenCredentials, subscriptionId: string) {
  return new StorageManagementClient(credentials, subscriptionId);
}
github Azure / ng-deploy-azure / src / builders / actions / deploy.ts View on Github external
}
  } 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(
github taskcluster / taskcluster / infrastructure / tooling / src / dev / azure.js View on Github external
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,
github microsoft / VoTT / src / services / authenticationService.ts View on Github external
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;
    }
}
github serverless / serverless-azure-functions / src / services / azureBlobStorageService.ts View on Github external
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;
  }
github serverless / serverless-azure-functions / src / services / azureBlobStorageService.ts View on Github external
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;
  }
github microsoft / VoTT / src / services / authenticationService.ts View on Github external
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;
    }
}

@azure/arm-storage

A generated SDK for StorageManagementClient.

MIT
Latest version published 8 months ago

Package Health Score

86 / 100
Full package analysis