{"id":30426233,"url":"https://github.com/bluzzi/typescript-azure-storage-cheatsheet","last_synced_at":"2025-08-22T12:44:23.124Z","repository":{"id":305413467,"uuid":"1022807053","full_name":"Bluzzi/TypeScript-Azure-Storage-Cheatsheet","owner":"Bluzzi","description":"Several examples of using Azure Storage (Blob) with TypeScript and the @azure/storage-blob package.","archived":false,"fork":false,"pushed_at":"2025-07-19T22:54:17.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-20T00:55:57.307Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bluzzi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-19T21:48:21.000Z","updated_at":"2025-07-19T22:59:42.000Z","dependencies_parsed_at":"2025-07-20T01:08:54.243Z","dependency_job_id":null,"html_url":"https://github.com/Bluzzi/TypeScript-Azure-Storage-Cheatsheet","commit_stats":null,"previous_names":["bluzzi/typescript-azure-storage-cheatsheet"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Bluzzi/TypeScript-Azure-Storage-Cheatsheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bluzzi%2FTypeScript-Azure-Storage-Cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bluzzi%2FTypeScript-Azure-Storage-Cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bluzzi%2FTypeScript-Azure-Storage-Cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bluzzi%2FTypeScript-Azure-Storage-Cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bluzzi","download_url":"https://codeload.github.com/Bluzzi/TypeScript-Azure-Storage-Cheatsheet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bluzzi%2FTypeScript-Azure-Storage-Cheatsheet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271641850,"owners_count":24795436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-22T12:44:19.672Z","updated_at":"2025-08-22T12:44:23.075Z","avatar_url":"https://github.com/Bluzzi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript Azure Storage (Blob) Cheatsheet\nThis repo contains several examples of using Azure Storage (Blob) with TypeScript and the `@azure/storage-blob` package.\n\nVarious examples of file uploads using different methods (from a URL, memory or a local file) are available, each with a synchronous and an asynchronous version.\n\n## Blob Types\nAzure Blob Storage supports three primary blob types, each tailored for specific use cases:\n\n1. Block Blob\n  - Description: Composed of blocks of data, it is the most common type used for storing files.\n  - Use Cases: Ideal for documents, images, videos, backups, and large binary files.\n  - Features: Supports parallel upload and optimized updates by managing blocks individually.\n2. Append Blob\n  - Description: Similar to block blobs but optimized for append operations, where data is appended to the end.\n  - Use Cases: Suitable for logging scenarios where append operations ensure data order, such as telemetry or real-time logging.\n  - Features: Data can only be added to the end, ensuring sequential write operations.\n3. Page Blob\n  - Description: Composed of fixed-size pages (512 bytes) optimized for frequent random read/write operations.\n  - Use Cases: Used for scenarios requiring random access to small data segments, like Azure VM disks (VHDs).\n  - Features: Provides low-latency access, ideal for virtual disks and applications requiring direct access to specific blob sections.\n\nIn this repository, we'll be concentrating on the use of Block Blob, but PRs are welcome if you'd like to add other examples for other types.\n\n## Client initialization\nEach example will use a `ContainerClient`, created from a `BlobServiceClient`, here's how they are initialized:\n```ts\nimport { BlobServiceClient, StorageSharedKeyCredential } from \"@azure/storage-blob\";\n\nexport const clientAzureStorage = new BlobServiceClient(\n  `https://${process.env.AZURE_STORAGE_ACCOUNT}.blob.core.windows.net`,\n  new StorageSharedKeyCredential(\n    process.env.AZURE_STORAGE_ACCOUNT,\n    process.env.AZURE_STORAGE_ACCOUNT_KEY,\n  ),\n);\n\nexport const containerClient = clientAzureStorage.getContainerClient(\n  process.env.AZURE_STORAGE_CONTAINER_NAME,\n);\n```\n\nSo we use a `StorageSharedKeyCredential` to handle authentication, but you can use any Azure authentication method you like.\n\n## Examples\n- [Client Initialization](./examples/client-initialization.ts)\n- [Upload a File via URL](./examples/upload-file-from-url.ts)\n- [Upload a File from Memory](./examples/upload-file-from-memory.ts)\n- [Upload a File from Local Disk](./examples/upload-file-from-local-disk.ts)\n- [Download a File Locally](./examples/download-file-locally.ts)\n- [Generate a \"Signed URL\" for Viewing a File (with GET HTTP request)](./examples/generate-viewing-file-url.ts)\n- [Generate a \"Signed URL\" for Uploading a File (with PUT HTTP request)](./examples/generate-uploading-file-url.ts)\n- [Retrieve File Size](./examples/retrieve-file-size.ts)\n- [Delete a File](./examples/delete-file.ts)\n- [Copy-Cut and Paste a File](./examples/copy-cut-paste-file.ts)\n- [Check that the File exists](./examples/check-file-exists.ts)\n- [Set CORS properties](./examples/set-cors-properties.ts)\n- [Enumerate Files with Specific Prefix](./examples/enumerate-files-with-prefix.ts)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluzzi%2Ftypescript-azure-storage-cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluzzi%2Ftypescript-azure-storage-cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluzzi%2Ftypescript-azure-storage-cheatsheet/lists"}