0.5.0
A simple client for Azure Storage and Key Vault REST API
Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
Dependencies
std
azure_storage_client
A simple client for Azure Storage REST API.
Usage
You need a connection string for your an Azure storage account. It has at least three fields:
- AccountName=*****;
- AccountKey=*****;
- EndpointSuffix=*****;
You can get it from the Azure portal.
import { Storage } from "https://deno.land/x/azure_storage_client@0.5.0/mod.ts"
let storage = new Storage(/* Connection string here */)
Blob Examples
Each method returns a Response object.
Create or Update
let res = await storage
.container('example') // A container name
.dir('dir') // A directory name
.file('file.txt') // A file name
.put(
new TextEncoder().encode('Hello World'), // Blob or BufferSource
'text/plain' // Content-Type
)
console.log('isSucceed:': res.ok)
Get
let text = await storage
.container('example')
.dir('dir')
.file('file.txt')
.get()
.then(res => res.text())
List
let text = await storage
.container('example')
.dir('dir')
.list()
.then(res => res.text())
Delete
let res = await storage
.container('example')
.dir('dir')
.file('file.txt')
.delete()
console.log('isDeleted:': res.ok)
Table Examples
Each method returns a Response object.
Create
let res = await storage
.table('example')
.partition('abc') // A partition key
.entity('def') // a row key
.post({
prop1: 'value' // A string or number or boolean
prop2: 100
})
console.log('isSucceed:': res.ok)
Get
let entity = await storage
.table('example')
.partition('abc')
.entity('def')
.get()
.then(res => res.json())
List
let entities = await storage
.table('example')
.partition('abc')
.list()
.then(res => res.json())
Update
let res = await storage
.table('example')
.partition('abc')
.entity('def')
.merge({
key2: 400
})
console.log('isSucceed:': res.ok)
Create or Update
let res = await storage
.table('example')
.partition('abc')
.entity('def')
.put({
key1: 'value'
key2: 400
})
console.log('isSucceed:': res.ok)
Delete
let res = await storage
.table('example')
.partition('abc')
.entity('def')
.delete()
console.log('isDeleted:': res.ok)