Added support for JavaScript UMD module

This commit is contained in:
Xiaoning Liu 2018-02-06 18:06:40 +08:00
Родитель 6890d9ff30
Коммит 260e89ab61
14 изменённых файлов: 278 добавлений и 286 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -44,3 +44,4 @@ blobservice_test.tmp
# Browserify bundle scripts
browser/bundle
browser/test

152
README.md
Просмотреть файл

@ -1,22 +1,22 @@
# Microsoft Azure Storage SDK for Node.js
# Microsoft Azure Storage SDK for Node.js and JavaScript for Browsers
[![NPM version](https://badge.fury.io/js/azure-storage.svg)](http://badge.fury.io/js/azure-storage) [![Slack](https://azurestorageslack.azurewebsites.net/badge.svg)]( https://azurestorageslack.azurewebsites.net)
* Master [![Build Status](https://travis-ci.org/Azure/azure-storage-node.svg?branch=master)](https://travis-ci.org/Azure/azure-storage-node/branches) [![Coverage Status](https://coveralls.io/repos/Azure/azure-storage-node/badge.svg?branch=master&service=github)](https://coveralls.io/github/Azure/azure-storage-node?branch=master)
* Dev [![Build Status](https://travis-ci.org/Azure/azure-storage-node.svg?branch=dev)](https://travis-ci.org/Azure/azure-storage-node/branches) [![Coverage Status](https://coveralls.io/repos/Azure/azure-storage-node/badge.svg?branch=dev&service=github)](https://coveralls.io/github/Azure/azure-storage-node?branch=dev)
This project provides a Node.js package and a browser compatible [JavaScript Client Library](#azure-storage-javascript-client-library-for-browsers) that makes it easy to consume and manage Microsoft Azure Storage Services.
This project provides a Node.js package and a browser compatible [JavaScript Client Library](https://github.com/Azure/azure-storage-node#azure-storage-javascript-client-library-for-browsers) that makes it easy to consume and manage Microsoft Azure Storage Services.
> If you are looking for the Node.js SDK for other Azure services, visit [https://github.com/Azure/azure-sdk-for-node](https://github.com/Azure/azure-sdk-for-node).
# Features
- Tables
- Create/Delete Tables
- Query/Create/Read/Update/Delete Entities
- Blobs
- Create/Delete Containers
- Create/Read/Update/Delete Blobs
- Tables
- Create/Delete Tables
- Query/Create/Read/Update/Delete Entities
- Files
- Create/Delete Shares
- Create/Delete Directories
@ -51,6 +51,75 @@ When using the Storage SDK, you must provide connection information for the stor
* Constructors - For example, `var tableSvc = azure.createTableService(accountName, accountKey);`
### Blob Storage
The **createContainerIfNotExists** method can be used to create a
container in which to store a blob:
```Javascript
var azure = require('azure-storage');
var blobService = azure.createBlobService();
blobService.createContainerIfNotExists('taskcontainer', {
publicAccessLevel: 'blob'
}, function(error, result, response) {
if (!error) {
// if result = true, container was created.
// if result = false, container already existed.
}
});
```
To upload a file (assuming it is called task1-upload.txt and it is placed in the same folder as the script below), the method **createBlockBlobFromLocalFile** can be used.
```Javascript
var azure = require('azure-storage');
var blobService = azure.createBlobService();
blobService.createBlockBlobFromLocalFile('mycontainer', 'taskblob', 'task1-upload.txt', function(error, result, response) {
if (!error) {
// file uploaded
}
});
```
For page blobs, use **createPageBlobFromLocalFile**. There are other methods for uploading blobs also, such as **createBlockBlobFromText** or **createPageBlobFromStream**.
There are also several ways to download block and page blobs. For example, **getBlobToStream** downloads the blob to a stream:
```Javascript
var blobService = azure.createBlobService();
var fs = require('fs');
blobService.getBlobToStream('mycontainer', 'taskblob', fs.createWriteStream('output.txt'), function(error, result, response) {
if (!error) {
// blob retrieved
}
});
```
To create a Shared Access Signature (SAS), use the **generateSharedAccessSignature** method. Additionally you can use the **date** helper functions to easily create a SAS that expires at some point relative to the current time.
```Javascript
var azure = require('azure-storage');
var blobService = azure.createBlobService();
var startDate = new Date();
var expiryDate = new Date(startDate);
expiryDate.setMinutes(startDate.getMinutes() + 100);
startDate.setMinutes(startDate.getMinutes() - 100);
var sharedAccessPolicy = {
AccessPolicy: {
Permissions: azure.BlobUtilities.SharedAccessPermissions.READ,
Start: startDate,
Expiry: expiryDate
}
};
var token = blobService.generateSharedAccessSignature(containerName, blobName, sharedAccessPolicy);
var sasUrl = blobService.getUrl(containerName, blobName, token);
```
### Table Storage
To ensure a table exists, call **createTableIfNotExists**:
@ -146,75 +215,6 @@ tableService.queryEntities('mytable', query, null, function(error, result, respo
});
```
### Blob Storage
The **createContainerIfNotExists** method can be used to create a
container in which to store a blob:
```Javascript
var azure = require('azure-storage');
var blobService = azure.createBlobService();
blobService.createContainerIfNotExists('taskcontainer', {
publicAccessLevel: 'blob'
}, function(error, result, response) {
if (!error) {
// if result = true, container was created.
// if result = false, container already existed.
}
});
```
To upload a file (assuming it is called task1-upload.txt and it is placed in the same folder as the script below), the method **createBlockBlobFromLocalFile** can be used.
```Javascript
var azure = require('azure-storage');
var blobService = azure.createBlobService();
blobService.createBlockBlobFromLocalFile('mycontainer', 'taskblob', 'task1-upload.txt', function(error, result, response) {
if (!error) {
// file uploaded
}
});
```
For page blobs, use **createPageBlobFromLocalFile**. There are other methods for uploading blobs also, such as **createBlockBlobFromText** or **createPageBlobFromStream**.
There are also several ways to download block and page blobs. For example, **getBlobToStream** downloads the blob to a stream:
```Javascript
var blobService = azure.createBlobService();
var fs = require('fs');
blobService.getBlobToStream('mycontainer', 'taskblob', fs.createWriteStream('output.txt'), function(error, result, response) {
if (!error) {
// blob retrieved
}
});
```
To create a Shared Access Signature (SAS), use the **generateSharedAccessSignature** method. Additionally you can use the **date** helper functions to easily create a SAS that expires at some point relative to the current time.
```Javascript
var azure = require('azure-storage');
var blobService = azure.createBlobService();
var startDate = new Date();
var expiryDate = new Date(startDate);
expiryDate.setMinutes(startDate.getMinutes() + 100);
startDate.setMinutes(startDate.getMinutes() - 100);
var sharedAccessPolicy = {
AccessPolicy: {
Permissions: azure.BlobUtilities.SharedAccessPermissions.READ,
Start: startDate,
Expiry: expiryDate
}
};
var token = blobService.generateSharedAccessSignature(containerName, blobName, sharedAccessPolicy);
var sasUrl = blobService.getUrl(containerName, blobName, token);
```
### Queue Storage
The **createQueueIfNotExists** method can be used to ensure a queue exists:
@ -515,7 +515,7 @@ On Linux, please use `export` other than `set` to set the variables.
Azure Storage Node.js Client Library is compatible with [Browserify](http://browserify.org/). This means you can bundle your Node.js application which depends on the Node.js Client Library using Browserify.
You can also choose to download the JavaScript Client Library provided by us, or generate the library by yourself. Please refer to the [README.md](browser/README.md) under `browser` folder for detailed usage guidelines.
You can also choose to download the JavaScript Client Library provided by us, or generate the library by yourself. Please refer to the [README.md](https://github.com/Azure/azure-storage-node/blob/master/browser/README.md) under `browser` folder for detailed usage guidelines.
## Downloading Azure Storage JavaScript Client Library
@ -523,7 +523,7 @@ It's recommended to use the Azure Storage JavaScript Client Library provided by
## Generating Azure Storage JavaScript Client Library
We also provide browserify bundle scripts which generate Azure Storage JavaScript Client Library. The bundle script reduces the size of the Storage Client Library by splitting into smaller files, one per storage service and a common shared file. For more detailed information, refer to [README.md](browser/README.md) under `browser` folder.
We also provide browserify bundle scripts which generate Azure Storage JavaScript Client Library. The bundle script reduces the size of the Storage Client Library by splitting into smaller files, one per storage service and a common shared file. For more detailed information, refer to [README.md](https://github.com/Azure/azure-storage-node/blob/master/browser/README.md) under `browser` folder.
# JsDoc

Просмотреть файл

@ -1,5 +1,10 @@
Note: This is the change log file for Azure Storage JavaScript Client Library.
2018.03 Version 0.2.8-preview.15
* Supported UMD module standard.
* Drop `azure-storage.common.js`.
2018.02 Version 0.2.8-preview.14
* Generated browser compatible JavaScript files based on Microsoft Azure Storage SDK for Node.js 2.8.0.

Просмотреть файл

@ -2,16 +2,15 @@
* Join the community discussion on Slack! [![Slack](https://azurestorageslack.azurewebsites.net/badge.svg)]( https://azurestorageslack.azurewebsites.net)
There are 5 generated JavaScript files for Azure Storage JavaScript Client Library:
- `azure-storage.common.js` contains the common part for other 4 JavaScript files.
- `azure-storage.table.js` contains the Azure Storage table service operation logic, which depends on azure-storage.common.js
- `azure-storage.blob.js` contains the Azure Storage blob service operation logic, which depends on azure-storage.common.js
- `azure-storage.queue.js` contains the Azure Storage queue service operation logic, which depends on azure-storage.common.js
- `azure-storage.file.js` contains the Azure Storage file service operation logic, which depends on azure-storage.common.js
There are 8 generated JavaScript files for Azure Storage JavaScript Client Library:
- `azure-storage.blob.js` and `azure-storage.blob.min.js` contain the Azure Storage blob service operation logic
- `azure-storage.table.js` and `azure-storage.table.min.js` contain the Azure Storage table service operation logic
- `azure-storage.queue.js` and `azure-storage.queue.min.js` contain the Azure Storage queue service operation logic
- `azure-storage.file.js` and `azure-storage.file.min.js` contain the Azure Storage file service operation logic
We also provide samples to guide you quickly start with the Azure Storage JavaScript Client Library. In the [JavaScript Client Library zip file](https://aka.ms/downloadazurestoragejs) or [azure-storage-node/browser/samples](samples), you will find 4 HTML samples:
- `sample-table.html` demonstrates how to operate with Azure Storage table service in the browser
- `sample-blob.html` demonstrates how to operate with Azure Storage blob service in the browser
- `sample-table.html` demonstrates how to operate with Azure Storage table service in the browser
- `sample-queue.html` demonstrates how to operate with Azure Storage queue service in the browser
- `sample-file.html` demonstrates how to operate with Azure Storage file service in the browser
@ -19,13 +18,17 @@ After generating the JavaScript Client Library, you can try the samples in brows
**Note**: An HTTP server should be set to host the samples for IE browser.
## Limitations
## Module Support
The Azure Storage JavaScript Client Library is currently in preview stage, there are some known issues or limitations as follows.
Above JavaScript files are all [UMD compatible](https://github.com/umdjs/umd). You can load them in a CommonJS or AMD environment by JavaScript module loaders. If no module system is found, following global variables will be set:
- `AzureStorage.Blob`
- `AzureStorage.Table`
- `AzureStorage.Queue`
- `AzureStorage.File`
### Compatibility
## Compatibility
Compatibility with mobile browsers have not been fully validated, please open issues when you get errors. Current validated browsers are as below:
Compatibility with mobile browsers have not been fully validated, please open issues when you get errors. Latest validated browser versions are as below:
| Chrome | Firefox | Internet Explorer | Microsoft Edge |
|------------|----------|--------------------|-----------------|
@ -37,12 +40,15 @@ If you wish to customize the library and generate the Azure Storage JavaScript C
We provide browserify bundle scripts which generate Azure Storage JavaScript Client Library. The bundle script reduces the size of the Storage Client Library by splitting into smaller files, one per storage service and a common shared file.
The generated JavaScript Client Library includes 5 separated JavaScript files:
- `azure-storage.common.js`
- `azure-storage.table.js`
The generated JavaScript Client Library includes 8 separated JavaScript files:
- `azure-storage.blob.js`
- `azure-storage.table.js`
- `azure-storage.queue.js`
- `azure-storage.file.js`
- `azure-storage.blob.min.js`
- `azure-storage.table.min.js`
- `azure-storage.queue.min.js`
- `azure-storage.file.min.js`
Let's get started to generate the Azure Storage JavaScript Client Library!
@ -73,34 +79,17 @@ npm install
We provide bundle scripts to help quickly generate the JavaScript Client Library. At the root directory of the cloned repo:
```Batchfile
npm run genjs
npm run genjs [VERSION_NUMBER]
```
### Step 4: Finding the Generated JavaScript Files
If everything goes well, the generated JavaScript files should be saved to `azure-storage-node/browser/bundle`. There will be 5 generated JavaScript files totally:
- `azure-storage.common.js`
- `azure-storage.table.js`
If everything goes well, the generated JavaScript files should be saved to `azure-storage-node/browser/bundle`. There will be 8 generated JavaScript files totally:
- `azure-storage.blob.js`
- `azure-storage.table.js`
- `azure-storage.queue.js`
- `azure-storage.file.js`
### Step 5: JavaScript Files Minify
You are able to minify the generated JavaScript files with your favorite minify tools. Here we show the minify process with Node.js minify tool [uglifyJS](https://github.com/mishoo/UglifyJS2).
Install uglifyJS:
```Batchfile
npm install -g uglify-js
```
Minify the JavaScript files:
```Batchfile
uglifyjs --compress --mangle -- azure-storage.common.js > azure-storage.common.min.js
uglifyjs --compress --mangle -- azure-storage.table.js > azure-storage.table.min.js
uglifyjs --compress --mangle -- azure-storage.blob.js > azure-storage.blob.min.js
uglifyjs --compress --mangle -- azure-storage.queue.js > azure-storage.queue.min.js
uglifyjs --compress --mangle -- azure-storage.file.js > azure-storage.file.min.js
```
- `azure-storage.blob.min.js`
- `azure-storage.table.min.js`
- `azure-storage.queue.min.js`
- `azure-storage.file.min.js`

Просмотреть файл

@ -14,9 +14,7 @@
// limitations under the License.
//
var AzureStorage = window.AzureStorage || {};
AzureStorage.generateDevelopmentStorageCredentials = function (proxyUri) {
module.exports.generateDevelopmentStorageCredentials = function (proxyUri) {
var devStore = 'UseDevelopmentStorage=true;';
if(proxyUri){
devStore += 'DevelopmentStorageProxyUri=' + proxyUri;
@ -27,18 +25,18 @@ AzureStorage.generateDevelopmentStorageCredentials = function (proxyUri) {
var BlobService = require('../lib/services/blob/blobservice.browser');
AzureStorage.BlobService = BlobService;
AzureStorage.BlobUtilities = require('../lib/services/blob/blobutilities');
module.exports.BlobService = BlobService;
module.exports.BlobUtilities = require('../lib/services/blob/blobutilities');
AzureStorage.createBlobService = function (storageAccountOrConnectionString, storageAccessKey, host) {
module.exports.createBlobService = function (storageAccountOrConnectionString, storageAccessKey, host) {
return new BlobService(storageAccountOrConnectionString, storageAccessKey, host, null);
};
AzureStorage.createBlobServiceWithSas = function (host, sasToken) {
module.exports.createBlobServiceWithSas = function (host, sasToken) {
return new BlobService(null, null, host, sasToken);
};
AzureStorage.createBlobServiceAnonymous = function (host) {
module.exports.createBlobServiceAnonymous = function (host) {
return new BlobService(null, null, host, null);
};
@ -46,7 +44,7 @@ var azureCommon = require('../lib/common/common.browser');
var StorageServiceClient = azureCommon.StorageServiceClient;
var SharedKey = azureCommon.SharedKey;
AzureStorage.generateAccountSharedAccessSignature = function(storageAccountOrConnectionString, storageAccessKey, sharedAccessAccountPolicy)
module.exports.generateAccountSharedAccessSignature = function(storageAccountOrConnectionString, storageAccessKey, sharedAccessAccountPolicy)
{
var storageSettings = StorageServiceClient.getStorageSettings(storageAccountOrConnectionString, storageAccessKey);
var sharedKey = new SharedKey(storageSettings._name, storageSettings._key);
@ -54,20 +52,18 @@ AzureStorage.generateAccountSharedAccessSignature = function(storageAccountOrCon
return sharedKey.generateAccountSignedQueryString(sharedAccessAccountPolicy);
};
AzureStorage.Constants = azureCommon.Constants;
AzureStorage.StorageUtilities = azureCommon.StorageUtilities;
AzureStorage.AccessCondition = azureCommon.AccessCondition;
module.exports.Constants = azureCommon.Constants;
module.exports.StorageUtilities = azureCommon.StorageUtilities;
module.exports.AccessCondition = azureCommon.AccessCondition;
AzureStorage.SR = azureCommon.SR;
AzureStorage.StorageServiceClient = StorageServiceClient;
AzureStorage.Logger = azureCommon.Logger;
AzureStorage.WebResource = azureCommon.WebResource;
AzureStorage.Validate = azureCommon.validate;
AzureStorage.date = azureCommon.date;
module.exports.SR = azureCommon.SR;
module.exports.StorageServiceClient = StorageServiceClient;
module.exports.Logger = azureCommon.Logger;
module.exports.WebResource = azureCommon.WebResource;
module.exports.Validate = azureCommon.validate;
module.exports.date = azureCommon.date;
// Other filters
AzureStorage.LinearRetryPolicyFilter = azureCommon.LinearRetryPolicyFilter;
AzureStorage.ExponentialRetryPolicyFilter = azureCommon.ExponentialRetryPolicyFilter;
AzureStorage.RetryPolicyFilter = azureCommon.RetryPolicyFilter;
window.AzureStorage = AzureStorage;
module.exports.LinearRetryPolicyFilter = azureCommon.LinearRetryPolicyFilter;
module.exports.ExponentialRetryPolicyFilter = azureCommon.ExponentialRetryPolicyFilter;
module.exports.RetryPolicyFilter = azureCommon.RetryPolicyFilter;

Просмотреть файл

@ -14,9 +14,7 @@
// limitations under the License.
//
var AzureStorage = window.AzureStorage || {};
AzureStorage.generateDevelopmentStorageCredentials = function (proxyUri) {
module.exports.generateDevelopmentStorageCredentials = function (proxyUri) {
var devStore = 'UseDevelopmentStorage=true;';
if(proxyUri){
devStore += 'DevelopmentStorageProxyUri=' + proxyUri;
@ -27,14 +25,14 @@ AzureStorage.generateDevelopmentStorageCredentials = function (proxyUri) {
var FileService = require('../lib/services/file/fileservice.browser');
AzureStorage.FileService = FileService;
AzureStorage.FileUtilities = require('../lib/services/file/fileutilities');
module.exports.FileService = FileService;
module.exports.FileUtilities = require('../lib/services/file/fileutilities');
AzureStorage.createFileService = function (storageAccountOrConnectionString, storageAccessKey, host) {
module.exports.createFileService = function (storageAccountOrConnectionString, storageAccessKey, host) {
return new FileService(storageAccountOrConnectionString, storageAccessKey, host);
};
AzureStorage.createFileServiceWithSas = function (hostUri, sasToken) {
module.exports.createFileServiceWithSas = function (hostUri, sasToken) {
return new FileService(null, null, hostUri, sasToken);
};
@ -42,7 +40,7 @@ var azureCommon = require('../lib/common/common.browser');
var StorageServiceClient = azureCommon.StorageServiceClient;
var SharedKey = azureCommon.SharedKey;
AzureStorage.generateAccountSharedAccessSignature = function(storageAccountOrConnectionString, storageAccessKey, sharedAccessAccountPolicy)
module.exports.generateAccountSharedAccessSignature = function(storageAccountOrConnectionString, storageAccessKey, sharedAccessAccountPolicy)
{
var storageSettings = StorageServiceClient.getStorageSettings(storageAccountOrConnectionString, storageAccessKey);
var sharedKey = new SharedKey(storageSettings._name, storageSettings._key);
@ -50,20 +48,18 @@ AzureStorage.generateAccountSharedAccessSignature = function(storageAccountOrCon
return sharedKey.generateAccountSignedQueryString(sharedAccessAccountPolicy);
};
AzureStorage.Constants = azureCommon.Constants;
AzureStorage.StorageUtilities = azureCommon.StorageUtilities;
AzureStorage.AccessCondition = azureCommon.AccessCondition;
module.exports.Constants = azureCommon.Constants;
module.exports.StorageUtilities = azureCommon.StorageUtilities;
module.exports.AccessCondition = azureCommon.AccessCondition;
AzureStorage.SR = azureCommon.SR;
AzureStorage.StorageServiceClient = StorageServiceClient;
AzureStorage.Logger = azureCommon.Logger;
AzureStorage.WebResource = azureCommon.WebResource;
AzureStorage.Validate = azureCommon.validate;
AzureStorage.date = azureCommon.date;
module.exports.SR = azureCommon.SR;
module.exports.StorageServiceClient = StorageServiceClient;
module.exports.Logger = azureCommon.Logger;
module.exports.WebResource = azureCommon.WebResource;
module.exports.Validate = azureCommon.validate;
module.exports.date = azureCommon.date;
// Other filters
AzureStorage.LinearRetryPolicyFilter = azureCommon.LinearRetryPolicyFilter;
AzureStorage.ExponentialRetryPolicyFilter = azureCommon.ExponentialRetryPolicyFilter;
AzureStorage.RetryPolicyFilter = azureCommon.RetryPolicyFilter;
window.AzureStorage = AzureStorage;
module.exports.LinearRetryPolicyFilter = azureCommon.LinearRetryPolicyFilter;
module.exports.ExponentialRetryPolicyFilter = azureCommon.ExponentialRetryPolicyFilter;
module.exports.RetryPolicyFilter = azureCommon.RetryPolicyFilter;

Просмотреть файл

@ -14,9 +14,7 @@
// limitations under the License.
//
var AzureStorage = window.AzureStorage || {};
AzureStorage.generateDevelopmentStorageCredentials = function (proxyUri) {
module.exports.generateDevelopmentStorageCredentials = function (proxyUri) {
var devStore = 'UseDevelopmentStorage=true;';
if(proxyUri){
devStore += 'DevelopmentStorageProxyUri=' + proxyUri;
@ -27,15 +25,15 @@ AzureStorage.generateDevelopmentStorageCredentials = function (proxyUri) {
var QueueService = require('../lib/services/queue/queueservice');
AzureStorage.QueueService = QueueService;
AzureStorage.QueueUtilities = require('../lib/services/queue/queueutilities');
AzureStorage.QueueMessageEncoder = require('../lib/services/queue/queuemessageencoder');
module.exports.QueueService = QueueService;
module.exports.QueueUtilities = require('../lib/services/queue/queueutilities');
module.exports.QueueMessageEncoder = require('../lib/services/queue/queuemessageencoder');
AzureStorage.createQueueService = function (storageAccountOrConnectionString, storageAccessKey, host) {
module.exports.createQueueService = function (storageAccountOrConnectionString, storageAccessKey, host) {
return new QueueService(storageAccountOrConnectionString, storageAccessKey, host);
};
AzureStorage.createQueueServiceWithSas = function(hostUri, sasToken) {
module.exports.createQueueServiceWithSas = function(hostUri, sasToken) {
return new QueueService(null, null, hostUri, sasToken);
};
@ -43,7 +41,7 @@ var azureCommon = require('../lib/common/common.browser');
var StorageServiceClient = azureCommon.StorageServiceClient;
var SharedKey = azureCommon.SharedKey;
AzureStorage.generateAccountSharedAccessSignature = function(storageAccountOrConnectionString, storageAccessKey, sharedAccessAccountPolicy)
module.exports.generateAccountSharedAccessSignature = function(storageAccountOrConnectionString, storageAccessKey, sharedAccessAccountPolicy)
{
var storageSettings = StorageServiceClient.getStorageSettings(storageAccountOrConnectionString, storageAccessKey);
var sharedKey = new SharedKey(storageSettings._name, storageSettings._key);
@ -51,20 +49,18 @@ AzureStorage.generateAccountSharedAccessSignature = function(storageAccountOrCon
return sharedKey.generateAccountSignedQueryString(sharedAccessAccountPolicy);
};
AzureStorage.Constants = azureCommon.Constants;
AzureStorage.StorageUtilities = azureCommon.StorageUtilities;
AzureStorage.AccessCondition = azureCommon.AccessCondition;
module.exports.Constants = azureCommon.Constants;
module.exports.StorageUtilities = azureCommon.StorageUtilities;
module.exports.AccessCondition = azureCommon.AccessCondition;
AzureStorage.SR = azureCommon.SR;
AzureStorage.StorageServiceClient = StorageServiceClient;
AzureStorage.Logger = azureCommon.Logger;
AzureStorage.WebResource = azureCommon.WebResource;
AzureStorage.Validate = azureCommon.validate;
AzureStorage.date = azureCommon.date;
module.exports.SR = azureCommon.SR;
module.exports.StorageServiceClient = StorageServiceClient;
module.exports.Logger = azureCommon.Logger;
module.exports.WebResource = azureCommon.WebResource;
module.exports.Validate = azureCommon.validate;
module.exports.date = azureCommon.date;
// Other filters
AzureStorage.LinearRetryPolicyFilter = azureCommon.LinearRetryPolicyFilter;
AzureStorage.ExponentialRetryPolicyFilter = azureCommon.ExponentialRetryPolicyFilter;
AzureStorage.RetryPolicyFilter = azureCommon.RetryPolicyFilter;
window.AzureStorage = AzureStorage;
module.exports.LinearRetryPolicyFilter = azureCommon.LinearRetryPolicyFilter;
module.exports.ExponentialRetryPolicyFilter = azureCommon.ExponentialRetryPolicyFilter;
module.exports.RetryPolicyFilter = azureCommon.RetryPolicyFilter;

Просмотреть файл

@ -14,9 +14,7 @@
// limitations under the License.
//
var AzureStorage = window.AzureStorage || {};
AzureStorage.generateDevelopmentStorageCredentials = function (proxyUri) {
module.exports.generateDevelopmentStorageCredentials = function (proxyUri) {
var devStore = 'UseDevelopmentStorage=true;';
if(proxyUri){
devStore += 'DevelopmentStorageProxyUri=' + proxyUri;
@ -26,16 +24,16 @@ AzureStorage.generateDevelopmentStorageCredentials = function (proxyUri) {
};
var TableService = require('../lib/services/table/tableservice');
AzureStorage.TableService = TableService;
AzureStorage.TableQuery = require('../lib/services/table/tablequery');
AzureStorage.TableBatch = require('../lib/services/table/tablebatch');
AzureStorage.TableUtilities = require('../lib/services/table/tableutilities');
module.exports.TableService = TableService;
module.exports.TableQuery = require('../lib/services/table/tablequery');
module.exports.TableBatch = require('../lib/services/table/tablebatch');
module.exports.TableUtilities = require('../lib/services/table/tableutilities');
AzureStorage.createTableService = function (storageAccountOrConnectionString, storageAccessKey, host) {
module.exports.createTableService = function (storageAccountOrConnectionString, storageAccessKey, host) {
return new TableService(storageAccountOrConnectionString, storageAccessKey, host);
};
AzureStorage.createTableServiceWithSas = function (hostUri, sasToken) {
module.exports.createTableServiceWithSas = function (hostUri, sasToken) {
return new TableService(null, null, hostUri, sasToken);
};
@ -43,7 +41,7 @@ var azureCommon = require('../lib/common/common.browser');
var StorageServiceClient = azureCommon.StorageServiceClient;
var SharedKey = azureCommon.SharedKey;
AzureStorage.generateAccountSharedAccessSignature = function(storageAccountOrConnectionString, storageAccessKey, sharedAccessAccountPolicy)
module.exports.generateAccountSharedAccessSignature = function(storageAccountOrConnectionString, storageAccessKey, sharedAccessAccountPolicy)
{
var storageSettings = StorageServiceClient.getStorageSettings(storageAccountOrConnectionString, storageAccessKey);
var sharedKey = new SharedKey(storageSettings._name, storageSettings._key);
@ -51,20 +49,18 @@ AzureStorage.generateAccountSharedAccessSignature = function(storageAccountOrCon
return sharedKey.generateAccountSignedQueryString(sharedAccessAccountPolicy);
};
AzureStorage.Constants = azureCommon.Constants;
AzureStorage.StorageUtilities = azureCommon.StorageUtilities;
AzureStorage.AccessCondition = azureCommon.AccessCondition;
module.exports.Constants = azureCommon.Constants;
module.exports.StorageUtilities = azureCommon.StorageUtilities;
module.exports.AccessCondition = azureCommon.AccessCondition;
AzureStorage.SR = azureCommon.SR;
AzureStorage.StorageServiceClient = StorageServiceClient;
AzureStorage.Logger = azureCommon.Logger;
AzureStorage.WebResource = azureCommon.WebResource;
AzureStorage.Validate = azureCommon.validate;
AzureStorage.date = azureCommon.date;
module.exports.SR = azureCommon.SR;
module.exports.StorageServiceClient = StorageServiceClient;
module.exports.Logger = azureCommon.Logger;
module.exports.WebResource = azureCommon.WebResource;
module.exports.Validate = azureCommon.validate;
module.exports.date = azureCommon.date;
// Other filters
AzureStorage.LinearRetryPolicyFilter = azureCommon.LinearRetryPolicyFilter;
AzureStorage.ExponentialRetryPolicyFilter = azureCommon.ExponentialRetryPolicyFilter;
AzureStorage.RetryPolicyFilter = azureCommon.RetryPolicyFilter;
window.AzureStorage = AzureStorage;
module.exports.LinearRetryPolicyFilter = azureCommon.LinearRetryPolicyFilter;
module.exports.ExponentialRetryPolicyFilter = azureCommon.ExponentialRetryPolicyFilter;
module.exports.RetryPolicyFilter = azureCommon.RetryPolicyFilter;

Просмотреть файл

@ -15,35 +15,62 @@
//
var browserify = require('browserify');
var factor = require('factor-bundle');
var fs = require('fs');
var path = require('path');
var UglifyJS = require('uglify-js');
var version = process.argv[2] || process.env.AZURE_STORAGE_JAVASCRIPT_VERSION || '';
var license = [
'// Azure Storage JavaScript Client Library ' + version,
'// Copyright (c) Microsoft and contributors. All rights reserved.'
].join('\n') + '\n';
var outputFolder = 'bundle';
var outputFolderPath = path.resolve(__dirname, outputFolder);
console.log('Generating Azure Storage JavaScript Client Library to ' + outputFolderPath + ' ...\n');
console.log('Generating Azure Storage JavaScript Client Library to ' + outputFolderPath + ' ...');
if (version === '') {
console.warn(
'No version number provided.',
'Please set up a version number by first parameter of bundle.js or environment value AZURE_STORAGE_JAVASCRIPT_VERSION'
);
}
if (!fs.existsSync(outputFolderPath)) {
fs.mkdirSync(outputFolderPath);
}
var b = browserify([
path.resolve(__dirname, 'azure-storage.blob.export.js'),
path.resolve(__dirname, 'azure-storage.file.export.js'),
path.resolve(__dirname, 'azure-storage.queue.export.js'),
path.resolve(__dirname, 'azure-storage.table.export.js')
], {require: ['stream', 'util', 'buffer']});
function build(exportFilePath, outputFilePath, moduleName, isMinify) {
browserify(exportFilePath, {standalone: moduleName}).bundle(function (err, src) {
if (err) {
console.error('Failed when parsing', exportFilePath, err);
return;
}
b.plugin(factor, {
outputs: [
path.resolve(outputFolderPath, 'azure-storage.blob.js'),
path.resolve(outputFolderPath, 'azure-storage.file.js'),
path.resolve(outputFolderPath, 'azure-storage.queue.js'),
path.resolve(outputFolderPath, 'azure-storage.table.js')
]
});
var code = (src || '').toString();
if (isMinify) {
result = UglifyJS.minify(code.trim());
if (result.error) {
console.error('Minify failed when parsing', exportFilePath, err);
return;
}
b.bundle().pipe(
fs.createWriteStream(path.resolve(outputFolderPath, 'azure-storage.common.js'))
);
code = result.code;
}
var ws = fs.createWriteStream(outputFilePath);
ws.write(license);
ws.write(code);
ws.end();
});
}
build(path.resolve(__dirname, 'azure-storage.blob.export.js'), path.resolve(outputFolderPath, 'azure-storage.blob.js'), 'AzureStorage.Blob');
build(path.resolve(__dirname, 'azure-storage.table.export.js'), path.resolve(outputFolderPath, 'azure-storage.table.js'), 'AzureStorage.Table');
build(path.resolve(__dirname, 'azure-storage.queue.export.js'), path.resolve(outputFolderPath, 'azure-storage.queue.js'), 'AzureStorage.Queue');
build(path.resolve(__dirname, 'azure-storage.file.export.js'), path.resolve(outputFolderPath, 'azure-storage.file.js'), 'AzureStorage.File');
build(path.resolve(__dirname, 'azure-storage.blob.export.js'), path.resolve(outputFolderPath, 'azure-storage.blob.min.js'), 'AzureStorage.Blob', true);
build(path.resolve(__dirname, 'azure-storage.table.export.js'), path.resolve(outputFolderPath, 'azure-storage.table.min.js'), 'AzureStorage.Table', true);
build(path.resolve(__dirname, 'azure-storage.queue.export.js'), path.resolve(outputFolderPath, 'azure-storage.queue.min.js'), 'AzureStorage.Queue', true);
build(path.resolve(__dirname, 'azure-storage.file.export.js'), path.resolve(outputFolderPath, 'azure-storage.file.min.js'), 'AzureStorage.File', true);

Просмотреть файл

@ -40,10 +40,9 @@
<h2 id="step2">Step 2: Importing Azure Storage JavaScript Client Library</h2>
<p>
Importing <code>azure-storage.common.js</code> and <code>azure-storage.blob.js</code> in your HTML file for blob operations, and make sure <code>azure-storage.common.js</code> is in front of <code>azure-storage.blob.js</code>.
Importing <code>azure-storage.blob.js</code> in your HTML file for blob operations.
<p>
<pre>
&lt;script src="azure-storage.common.js"&gt;&lt;/script&gt;
&lt;script src="azure-storage.blob.js"&gt;&lt;/script&gt;
</pre>
@ -54,15 +53,15 @@
</p>
<pre>
var blobUri = 'https://' + 'STORAGE_ACCOUNT' + '.blob.core.windows.net';
var blobService = AzureStorage.createBlobServiceWithSas(blobUri, 'SAS_TOKEN');
var blobService = AzureStorage.Blob.createBlobServiceWithSas(blobUri, 'SAS_TOKEN');
</pre>
<p>
In Azure Storage JavaScript Client Library, a global variable <code>AzureStorage</code> is the start point where we can create service objects for blob/table/queue/file and access to the storage utilities.
You can load Azure Storage JavaScript Client Library in a CommonJS or AMD environment by JavaScript module loaders. If no module system is found, global variable <code>AzureStorage.Blob</code> will be set, which is the start point where we can create service objects for blob and access to the storage utilities.
</p>
<div class="panel panel-primary">
<div class="panel-body">
<b>How to get full detailed API definitions? </b> Currently, the JavaScript Client Library shares the same API definitions with Node.js SDK.
Please check API details on <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js API reference documents</a>. The JavaScript global variable <code>AzureStorage</code> is just like the object <code>require('azure-storage')</code> returns in Node.js.
<b>How to get full detailed API definitions? </b> Currently, the JavaScript Client Library shares almost the same API definitions with Node.js SDK.
Please check API details on <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js API reference documents</a>. The JavaScript global variable <code>AzureStorage.Blob</code> is just like the object <code>require('azure-storage')</code> returns in Node.js.
</div>
</div>
<div class="panel panel-danger">
@ -264,17 +263,14 @@ blobService.deleteBlobIfExists(container, blob, function(error, result) {
<h3 id="step6">Step 6: Creating your JavaScript Application based on Azure Storage JavaScript Client Library</h3>
<ul>
<li>1. Setting CORS rules for your selected Azure-Storage account blob service.</li>
<li>2. Including "azure-storage.common.js" in the html file.</li>
<li>3. Including functional file(s) needed, such as "azure-storage.blob.js" for blob operation.</li>
<li>4. Using keyword "AzureStorage" to access to Azure storage JavaScript APIs.</li>
<li>5. Referring to <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js SDK documents</a> for detailed API definitions which keep same with JavaScript APIs.</li>
<li>2. Including functional file(s) needed, such as "azure-storage.blob.js" for blob operation.</li>
<li>3. Using keyword "AzureStorage.Blob" to access to Azure storage JavaScript APIs for blobs.</li>
<li>4. Referring to <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js SDK documents</a> for detailed API definitions which keep same with JavaScript APIs.</li>
</ul>
<p> You can view the source code of this sample for detailed reference. </p>
</div>
<!-- azure-storage.common.js also exports Node.js module stream, util and buffer -->
<script src="../bundle/azure-storage.common.js"></script>
<script src="../bundle/azure-storage.blob.js"></script>
<script src="../bundle/azure-storage.blob.min.js"></script>
<script>
var account = document.getElementById('account').value;
@ -305,7 +301,7 @@ blobService.deleteBlobIfExists(container, blob, function(error, result) {
return null;
blobUri = 'https://' + account + '.blob.core.windows.net';
var blobService = AzureStorage.createBlobServiceWithSas(blobUri, sas).withFilter(new AzureStorage.ExponentialRetryPolicyFilter());
var blobService = AzureStorage.Blob.createBlobServiceWithSas(blobUri, sas).withFilter(new AzureStorage.Blob.ExponentialRetryPolicyFilter());
return blobService;
}
@ -366,7 +362,7 @@ blobService.deleteBlobIfExists(container, blob, function(error, result) {
return;
var container = document.getElementById('newcontainer').value;
if (!AzureStorage.Validate.containerNameIsValid(container, function(err, res){})) {
if (!AzureStorage.Blob.Validate.containerNameIsValid(container, function(err, res){})) {
alert('Invalid container name!');
return;
}

Просмотреть файл

@ -41,10 +41,9 @@
<h2 id="step2">Step 2: Importing Azure Storage JavaScript Files</h2>
<p>
Importing <code>azure-storage.common.js</code> and <code>azure-storage.file.js</code> in your HTML file for file operations, and make sure <code>azure-storage.common.js</code> is in front of <code>azure-storage.file.js</code>.
Importing <code>azure-storage.file.js</code> in your HTML file for file operations.
<p>
<pre>
&lt;script src="azure-storage.common.js"&gt;&lt;/script&gt;
&lt;script src="azure-storage.file.js"&gt;&lt;/script&gt;
</pre>
@ -55,15 +54,15 @@
</p>
<pre>
var fileUri = 'https://' + 'STORAGE_ACCOUNT' + '.file.core.windows.net';
var fileService = AzureStorage.createFileServiceWithSas(fileUri, 'SAS_TOKEN');
var fileService = AzureStorage.File.createFileServiceWithSas(fileUri, 'SAS_TOKEN');
</pre>
<p>
In Azure Storage JavaScript Client Library, a global variable <code>AzureStorage</code> is the start point where we can create service objects for blob/table/queue/file and access to the storage utilities.
You can load Azure Storage JavaScript Client Library in a CommonJS or AMD environment by JavaScript module loaders. If no module system is found, global variable <code>AzureStorage.File</code> will be set, which is the start point where we can create service objects for file and access to the storage utilities.
</p>
<div class="panel panel-primary">
<div class="panel-body">
<b>How to get full detailed API definitions? </b> Currently, the JavaScript Client Library shares the same API definitions with Node.js SDK.
Please check API details on <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js API reference documents</a>. The JavaScript global variable <code>AzureStorage</code> is just like the object <code>require('azure-storage')</code> returns in Node.js.
Please check API details on <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js API reference documents</a>. The JavaScript global variable <code>AzureStorage.File</code> is just like the object <code>require('azure-storage')</code> returns in Node.js.
</div>
</div>
<div class="panel panel-danger">
@ -265,15 +264,13 @@ fileService.deleteFileIfExists('myfileshare', 'mydirectory', 'myfile', function(
<h3 id="step6">Step 6: Creating your JavaScript Application based on Azure Storage JavaScript Client Library</h3>
<ul>
<li>1. Setting CORS rules for your selected Azure-Storage account file service.</li>
<li>2. Including "azure-storage.common.js" in the html file.</li>
<li>3. Including functional file(s) needed, such as "azure-storage.file.js" for file operation.</li>
<li>4. Using keyword "AzureStorage" to access to Azure storage JavaScript APIs.</li>
<li>5. Referring to <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js SDK documents</a> for detailed API definitions which keep same with JavaScript APIs.</li>
<li>2. Including functional file(s) needed, such as "azure-storage.file.js" for file operation.</li>
<li>3. Using keyword "AzureStorage.File" to access to Azure storage JavaScript APIs for files.</li>
<li>4. Referring to <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js SDK documents</a> for detailed API definitions which keep same with JavaScript APIs.</li>
</ul>
<p> You can view the source code of this sample for detailed reference. </p>
</div>
<script src="../bundle/azure-storage.common.js"></script>
<script src="../bundle/azure-storage.file.js"></script>
<script>
@ -307,7 +304,7 @@ fileService.deleteFileIfExists('myfileshare', 'mydirectory', 'myfile', function(
return null;
fileUri = 'https://' + account + '.file.core.windows.net';
var fileService = AzureStorage.createFileServiceWithSas(fileUri, sas).withFilter(new AzureStorage.ExponentialRetryPolicyFilter());
var fileService = AzureStorage.File.createFileServiceWithSas(fileUri, sas).withFilter(new AzureStorage.File.ExponentialRetryPolicyFilter());
return fileService;
}
@ -371,7 +368,7 @@ fileService.deleteFileIfExists('myfileshare', 'mydirectory', 'myfile', function(
return;
var share = document.getElementById('newfileshare').value;
if (!AzureStorage.Validate.shareNameIsValid(share, function(err, res){})) {
if (!AzureStorage.File.Validate.shareNameIsValid(share, function(err, res){})) {
alert('Invalid share name!');
return;
}

Просмотреть файл

@ -42,10 +42,9 @@
<h2 id="step2">Step 2: Importing Azure Storage JavaScript Client Library</h2>
<p>
Importing <code>azure-storage.common.js</code> and <code>azure-storage.queue.js</code> in your HTML file for queue operations, and make sure <code>azure-storage.common.js</code> is in front of <code>azure-storage.queue.js</code>.
Importing <code>azure-storage.queue.js</code> in your HTML file for queue operations.
<p>
<pre>
&lt;script src="azure-storage.common.js"&gt;&lt;/script&gt;
&lt;script src="azure-storage.queue.js"&gt;&lt;/script&gt;
</pre>
@ -56,15 +55,15 @@
</p>
<pre>
var queueUri = 'https://' + 'STORAGE_ACCOUNT' + '.queue.core.windows.net';
var queueService = AzureStorage.createQueueServiceWithSas(queueUri, 'SAS_TOKEN');
var queueService = AzureStorage.Queue.createQueueServiceWithSas(queueUri, 'SAS_TOKEN');
</pre>
<p>
In Azure Storage JavaScript Client Library, a global variable <code>AzureStorage</code> is the start point where we can create service objects for blob/table/queue/file and access to the storage utilities.
You can load Azure Storage JavaScript Client Library in a CommonJS or AMD environment by JavaScript module loaders. If no module system is found, global variable <code>AzureStorage.Queue</code> will be set, which is the start point where we can create service objects for queue and access to the storage utilities.
</p>
<div class="panel panel-primary">
<div class="panel-body">
<b>How to get full detailed API definitions? </b> Currently, the JavaScript Client Library shares the same API definitions with Node.js SDK.
Please check API details on <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js API reference documents</a>. The JavaScript global variable <code>AzureStorage</code> is just like the object <code>require('azure-storage')</code> returns in Node.js.
Please check API details on <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js API reference documents</a>. The JavaScript global variable <code>AzureStorage.Queue</code> is just like the object <code>require('azure-storage')</code> returns in Node.js.
</div>
</div>
<div class="panel panel-danger">
@ -136,7 +135,7 @@ queueService.deleteQueueIfExists('myqueue', function(error, result) {
<p> A storage <b>Message</b>, in any format, of up to 64 KB. The maximum time that a message can remain in the queue is 7 days.</p>
<div class="panel panel-primary">
<div class="panel-body">
<b>Note: </b> Azure Storage JavaScript Client Library provides <code>var encoder = new AzureStorage.QueueMessageEncoder.TextBase64QueueMessageEncoder()</code> which is a Base64 encoder and docoder.
<b>Note: </b> Azure Storage JavaScript Client Library provides <code>var encoder = new AzureStorage.Queue.QueueMessageEncoder.TextBase64QueueMessageEncoder()</code> which is a Base64 encoder and docoder.
If a message content string is encoded with <code>encoder.encode()</code>, remember to decode it with <code>encoder.decode()</code> after peek the message.
</div>
</div>
@ -158,7 +157,7 @@ queueService.peekMessages('myqueue', {numOfMessages: 32}, function (error, resul
<h3>Create Message</h3>
<p><code>QueueService</code> provides <code>createMessage</code> for creating a new message to a queue.</p>
<pre>
var encoder = new AzureStorage.QueueMessageEncoder.TextBase64QueueMessageEncoder();
var encoder = new AzureStorage.Queue.QueueMessageEncoder.TextBase64QueueMessageEncoder();
queueService.createMessage('myqueue', encoder.encode('mymessage'), function (error, results, response) {
if (error) {
// Create message error
@ -187,7 +186,7 @@ queueService.getMessages('myqueue', function(error, result, response) {
<h3>Update Message</h3>
<p><code>QueueService</code> provides <code>getMessages</code> and <code>updateMessage</code> for updating next message in a queue.</p>
<pre>
var encoder = new AzureStorage.QueueMessageEncoder.TextBase64QueueMessageEncoder();
var encoder = new AzureStorage.Queue.QueueMessageEncoder.TextBase64QueueMessageEncoder();
queueService.getMessages('myqueue', function(error, result, response) {
if(!error){
// Got the message
@ -219,23 +218,20 @@ queueService.getMessages('myqueue', function(error, result, response) {
<h2 id="step6">Step 6: Creating your JavaScript Application based on Azure Storage JavaScript Client Library</h2>
<ul>
<li>1. Setting CORS rules for your selected Azure-Storage account queue service.</li>
<li>2. Including "azure-storage.common.js" in the html file.</li>
<li>3. Including functional file(s) needed, such as "azure-storage.queue.js" for queue operation.</li>
<li>4. Using keyword "AzureStorage" to access to Azure storage JavaScript APIs.</li>
<li>5. Referring to <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js SDK documents</a> for detailed API definitions which keep same with JavaScript APIs.</li>
<li>2. Including functional file(s) needed, such as "azure-storage.queue.js" for queue operation.</li>
<li>3. Using keyword "AzureStorage.Queue" to access to Azure storage JavaScript APIs for queues.</li>
<li>4. Referring to <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js SDK documents</a> for detailed API definitions which keep same with JavaScript APIs.</li>
</ul>
<p> You can view the source code of this sample for detailed reference. </p>
</div>
<!-- azure-storage.common.js also exports Node.js module stream, util and buffer -->
<script src="../bundle/azure-storage.common.js"></script>
<script src="../bundle/azure-storage.queue.js"></script>
<script>
var account = document.getElementById('account').value;
var sas = document.getElementById('sas').value;
var queue = '';
var queueUri = '';
var encoder = new AzureStorage.QueueMessageEncoder.TextBase64QueueMessageEncoder();
var encoder = new AzureStorage.Queue.QueueMessageEncoder.TextBase64QueueMessageEncoder();
function checkParameters() {
account = document.getElementById('account').value;
@ -260,7 +256,7 @@ queueService.getMessages('myqueue', function(error, result, response) {
return null;
queueUri = 'https://' + account + '.queue.core.windows.net';
var queueService = AzureStorage.createQueueServiceWithSas(queueUri, sas).withFilter(new AzureStorage.ExponentialRetryPolicyFilter());
var queueService = AzureStorage.Queue.createQueueServiceWithSas(queueUri, sas).withFilter(new AzureStorage.Queue.ExponentialRetryPolicyFilter());
return queueService;
}
@ -304,7 +300,7 @@ queueService.getMessages('myqueue', function(error, result, response) {
return;
var queue = document.getElementById('newqueue').value;
if (!AzureStorage.Validate.queueNameIsValid(queue, function(err, res){})) {
if (!AzureStorage.Queue.Validate.queueNameIsValid(queue, function(err, res){})) {
alert('Invalid queue name!');
return;
}

Просмотреть файл

@ -42,10 +42,9 @@
<h2 id="step2">Step 2: Importing Azure Storage JavaScript Client Library</h2>
<p>
Importing <code>azure-storage.common.js</code> and <code>azure-storage.table.js</code> in your HTML file for table operations, and make sure <code>azure-storage.common.js</code> is in front of <code>azure-storage.table.js</code>.
Importing <code>azure-storage.table.js</code> in your HTML file for table operations.
<p>
<pre>
&lt;script src="azure-storage.common.js"&gt;&lt;/script&gt;
&lt;script src="azure-storage.table.js"&gt;&lt;/script&gt;
</pre>
@ -56,15 +55,15 @@
</p>
<pre>
var tableUri = 'https://' + 'STORAGE_ACCOUNT' + '.table.core.windows.net';
var tableService = AzureStorage.createTableServiceWithSas(tableUri, 'SAS_TOKEN');
var tableService = AzureStorage.Table.createTableServiceWithSas(tableUri, 'SAS_TOKEN');
</pre>
<p>
In Azure Storage JavaScript Client Library, a global variable <code>AzureStorage</code> is the start point where we can create service objects for blob/table/queue/file and access to the storage utilities.
You can load Azure Storage JavaScript Client Library in a CommonJS or AMD environment by JavaScript module loaders. If no module system is found, global variable <code>AzureStorage.Table</code> will be set, which is the start point where we can create service objects for table and access to the storage utilities.
</p>
<div class="panel panel-primary">
<div class="panel-body">
<b>How to get full detailed API definitions? </b> Currently, the JavaScript Client Library shares the same API definitions with Node.js SDK.
Please check API details on <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js API reference documents</a>. The JavaScript global variable <code>AzureStorage</code> is just like the object <code>require('azure-storage')</code> returns in Node.js.
Please check API details on <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js API reference documents</a>. The JavaScript global variable <code>AzureStorage.Table</code> is just like the object <code>require('azure-storage')</code> returns in Node.js.
</div>
</div>
<div class="panel panel-danger">
@ -139,7 +138,7 @@ tableService.deleteTableIfExists('mytable', function(error, result) {
<h3>Query Entities</h3>
<p><code>TableService</code> provides <code>queryEntities</code> for querying a table under a storage account.</p>
<pre>
var tableQuery = new AzureStorage.TableQuery().top(200);
var tableQuery = new AzureStorage.Table.TableQuery().top(200);
tableService.queryEntities('mytable', tableQuery, null, function(error, result) {
if (error) {
// Query entities error
@ -204,16 +203,13 @@ tableService.deleteEntity('mytable', deleteEntity, function(error, result, respo
<h3 id="step6">Step 6: Creating your JavaScript Application based on Azure Storage JavaScript Client Library</h3>
<ul>
<li>1. Setting CORS rules for your selected Azure-Storage account table service.</li>
<li>2. Including "azure-storage.common.js" in the html file.</li>
<li>3. Including functional file(s) needed, such as "azure-storage.table.js" for table operation.</li>
<li>4. Using keyword "AzureStorage" to access to Azure storage JavaScript APIs.</li>
<li>5. Referring to <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js SDK documents</a> for detailed API definitions which keep same with JavaScript APIs.</li>
<li>2. Including functional file(s) needed, such as "azure-storage.table.js" for table operation.</li>
<li>3. Using keyword "AzureStorage.Table" to access to Azure storage JavaScript APIs for tables.</li>
<li>4. Referring to <a href="http://azure.github.io/azure-storage-node/">Azure Storage Node.js SDK documents</a> for detailed API definitions which keep same with JavaScript APIs.</li>
</ul>
<p> You can view the source code of this sample for detailed reference. </p>
</div>
<!-- azure-storage.common.js also exports Node.js module stream, util and buffer -->
<script src="../bundle/azure-storage.common.js"></script>
<script src="../bundle/azure-storage.table.js"></script>
<script>
@ -245,7 +241,7 @@ tableService.deleteEntity('mytable', deleteEntity, function(error, result, respo
return null;
tableUri = 'https://' + account + '.table.core.windows.net';
var tableService = AzureStorage.createTableServiceWithSas(tableUri, sas).withFilter(new AzureStorage.ExponentialRetryPolicyFilter());
var tableService = AzureStorage.Table.createTableServiceWithSas(tableUri, sas).withFilter(new AzureStorage.Table.ExponentialRetryPolicyFilter());
return tableService;
}
@ -287,7 +283,7 @@ tableService.deleteEntity('mytable', deleteEntity, function(error, result, respo
return;
var table = document.getElementById('newtable').value;
if (!AzureStorage.Validate.tableNameIsValid(table, function(err, res){})) {
if (!AzureStorage.Table.Validate.tableNameIsValid(table, function(err, res){})) {
alert('Invalid table name!');
return;
}
@ -335,7 +331,7 @@ tableService.deleteEntity('mytable', deleteEntity, function(error, result, respo
}
document.getElementById('result').innerHTML = 'Loading table entities...';
var tableQuery = new AzureStorage.TableQuery().top(200);
var tableQuery = new AzureStorage.Table.TableQuery().top(200);
tableService.queryEntities(table, tableQuery, null, function(error, results) {
if (error) {
alert('List table entities error, please open browser console to view detailed error');

Просмотреть файл

@ -33,7 +33,7 @@
"xmlbuilder": "0.4.3"
},
"devDependencies": {
"browserify": "^13.3.0",
"browserify": "~15.2.0",
"batchflow": "0.4.0",
"coveralls": "^2.11.4",
"factor-bundle": "^2.5.0",
@ -51,7 +51,8 @@
"mocha-lcov-reporter": "^1.0.0",
"nock": "0.16",
"nsp": "^2.2.0",
"should": "1.2.x"
"should": "1.2.x",
"uglify-js": "~3.3.9"
},
"homepage": "http://github.com/Azure/azure-storage-node",
"repository": {