How to use the azure-storage.createFileService function in azure-storage

To help you get started, we’ve selected a few azure-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 Azure / azure-xplat-cli / test / commands / cli.storage.file-tests.js View on Github external
it('should prepare the source file and blob', function(done) {
          fileService = storage.createFileService(process.env.AZURE_STORAGE_CONNECTION_STRING);
          blobService = storage.createBlobService(process.env.AZURE_STORAGE_CONNECTION_STRING);
          fileService.createShareIfNotExists(sourceShare, function () {
            fileService.createShareIfNotExists(destShare, function () {
              var buf = new Buffer('HelloWorld', 'utf8');
              var fd = fs.openSync(localFileName, 'w');
              fs.writeSync(fd, buf, 0, buf.length, 0);
              fileService.createDirectoryIfNotExists(sourceShare, sourceDirectory, function (error) {
                assert.equal(error, null);
                fileService.createDirectoryIfNotExists(destShare, destDirectory, function (error) {
                  assert.equal(error, null);
                  fileService.createFileFromLocalFile(sourceShare, sourceDirectory, remoteFileName, localFileName, function (error) {
                    assert.equal(error, null);
                    blobService.createContainerIfNotExists(sourceContainer, function (error) {
                      assert.equal(error, null);
                      blobService.createBlockBlobFromLocalFile(sourceContainer, sourceBlob, localFileName, function (error) {
                        assert.equal(error, null);
github Azure / azure-xplat-cli / test / commands / cli.storage.blob-tests.js View on Github external
it('should prepare the source file and blob', function(done) {
          blobService = storage.createBlobService(process.env.AZURE_STORAGE_CONNECTION_STRING);
          fileService = storage.createFileService(process.env.AZURE_STORAGE_CONNECTION_STRING);
          blobService.createContainerIfNotExists(sourceContainer, function (error) {
            assert.equal(error, null);
            blobService.createContainerIfNotExists(destContainer, function (error) {
              assert.equal(error, null);
              var buf = new Buffer('HelloWorld', 'utf8');
              var fd = fs.openSync(fileName, 'w');
              fs.writeSync(fd, buf, 0, buf.length, 0);
              blobService.createBlockBlobFromLocalFile(sourceContainer, blobName, fileName, function (error) {
                assert.equal(error, null);
                fileService.createShareIfNotExists(sourceShare, function (error) {
                  assert.equal(error, null);
                  fileService.createDirectoryIfNotExists(sourceShare, sourceDir, function (error) {
                    assert.equal(error, null);
                    fileService.createFileFromLocalFile(sourceShare, sourceDir, fileName, fileName, function (error) {
                      assert.equal(error, null);
                      fs.unlinkSync(fileName);
github Azure / azure-xplat-cli / test / commands / cli.storage.file-tests.js View on Github external
after(function (done) {
        var fileService = storage.createFileService(process.env.AZURE_STORAGE_CONNECTION_STRING);
        fileService.deleteShare(shareName, function () { done(); });
      });
github Azure / azure-xplat-cli / test / commands / cli.storage.file-tests.js View on Github external
before(function (done) {
        var fileService = storage.createFileService(process.env.AZURE_STORAGE_CONNECTION_STRING);
        fileService.createShare(shareName, function () {
          fileService.createDirectory(shareName, prefix + directoryName, function () {
            var buf = new Buffer('HelloWord', 'utf8');
            for (var i = 0; i < testCount; i++) {
              var filePath = path.join(__dirname, i.toString() + localFile);
              var file = fs.openSync(filePath, 'w');
              fs.writeSync(file, buf, 0, buf.length, 0);
              testFiles.push(filePath);
              fileService.createFileFromLocalFile(shareName, '', prefix + i.toString() + remoteFile, filePath, function () {
                if (++pushed == testCount) {
                  done();
                }
              });
            }
          });
        });
github Azure / azure-sdk-for-node / test / services / batchaiManagement / batchaiManagementClient-tests.js View on Github external
const sharePromise = new Promise(function (resolve) {
              const fileService = AzureStorage.createFileService(storageAccountName, storageAccountKey);
              fileService.createShareIfNotExists(azFileShareName, function (err) {
                should.not.exist(err);
                resolve();
              });
            });
github Azure / azure-xplat-cli / test / commands / cli.storage.file-tests.js View on Github external
after(function (done) {
        for (var i = 0; i < testFiles.length; i++) {
          fs.unlinkSync(testFiles[i]);
        }

        var fileService = storage.createFileService(process.env.AZURE_STORAGE_CONNECTION_STRING);
        fileService.deleteShare(shareName, function () {
          fileService.deleteDirectory(shareName, directoryName, function () {
            done();
          });
        });
      });
github Azure / azure-xplat-cli / test / commands / cli.storage.blob-tests.js View on Github external
liveOnly('should prepare the source file and page blob', function(done) {
          var buf = crypto.randomBytes(512);
          var fd = fs.openSync(fileName, 'w');
          fs.writeSync(fd, buf, 0, buf.length, 0);

          blobService = storage.createBlobService(process.env.AZURE_STORAGE_CONNECTION_STRING);
          fileService = storage.createFileService(process.env.AZURE_STORAGE_CONNECTION_STRING);

          blobService.createContainerIfNotExists(sourceContainer, function (error) {
            assert.equal(error, null);
            blobService.createContainerIfNotExists(destContainer, function (error) {
              assert.equal(error, null);
              blobService.createPageBlobFromLocalFile(sourceContainer, blobName, fileName, function (error) {
                assert.equal(error, null);
                try { fs.unlinkSync(fileName); } catch(err) { }

                blobService.createBlobSnapshot(sourceContainer, blobName, function (error, snapshotId) {
                  assert.equal(error, null);
                  snapshot1 = snapshotId;
                
                  buf = crypto.randomBytes(512);
                  var fd = fs.openSync(fileName2, 'w');
                  fs.writeSync(fd, buf, 0, buf.length, 0);
github Azure / azure-xplat-cli / test / commands / cli.storage.file-tests.js View on Github external
before(function (done) {
        var fileService = storage.createFileService(process.env.AZURE_STORAGE_CONNECTION_STRING);
        fileService.createShare(shareName, function () { done(); });
      });
github microsoft / nni / src / nni_manager / training_service / kubernetes / kubernetesTrainingService.ts View on Github external
protected async createAzureStorage(vaultName: string, valutKeyName: string): Promise {
        try {
            const result: any = await cpp.exec(`az keyvault secret show --name ${valutKeyName} --vault-name ${vaultName}`);
            if (result.stderr) {
                const errorMessage: string = result.stderr;
                this.log.error(errorMessage);

                return Promise.reject(errorMessage);
            }
            const storageAccountKey: any = JSON.parse(result.stdout).value;
            if (this.azureStorageAccountName === undefined) {
                throw new Error('azureStorageAccountName not initialized!');
            }
            //create storage client
            this.azureStorageClient = azureStorage.createFileService(this.azureStorageAccountName, storageAccountKey);
            await AzureStorageClientUtility.createShare(this.azureStorageClient, this.azureStorageShare);
            //create sotrage secret
            this.azureStorageSecretName = String.Format('nni-secret-{0}', uniqueString(8)
                                                                            .toLowerCase());
            await this.genericK8sClient.createSecret(
                {
                    apiVersion: 'v1',
                    kind: 'Secret',
                    metadata: {
                        name: this.azureStorageSecretName,
                        namespace: 'default',
                        labels: {
                            app: this.NNI_KUBERNETES_TRIAL_LABEL,
                            expId: getExperimentId()
                        }
                    },