Skip to content

Commit ef3ceb5

Browse files
Merge pull request #2 from Azure/swapnil/SdkBlobBindingReadmeUpdate
Updating Readme and Linting issues
2 parents 408a923 + da73c5e commit ef3ceb5

File tree

6 files changed

+147
-163
lines changed

6 files changed

+147
-163
lines changed
Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,33 @@
1-
# To be created.
1+
# Azure Functions Node.js Extensions Base
2+
3+
The Azure Functions Node.js Extensions Base Library provides core interfaces, classes, and utilities for building extension components for Azure Functions in JavaScript and TypeScript to recognize and bind to SDK types. **It is not intended for direct use**. Instead, please reference one of the extending packages:
4+
5+
[@azure/functions-extensions-bindings-blob](https://github.com/Azure/azure-functions-nodejs-extensions/tree/main/azure-functions-nodejs-extensions-blob)
6+
7+
## Features
8+
9+
- **Resource Factory Resolver**: Core singleton class for registering and retrieving Azure resource factories
10+
- **Model Binding Support**: Types and interfaces for binding Azure resources to Function parameters
11+
- **Type-Safe Bindings**: Type definitions for supported Azure binding types
12+
- **Extension Registration**: Foundation for registering extensions in Azure Functions
13+
14+
## Integration with Azure Functions
15+
16+
This library serves as a foundation for Azure Functions extensions that provide additional bindings or integration capabilities. For examples of extensions built on this library, see:
17+
18+
- [@azure/functions-extensions-bindings-blob](https://github.com/Azure/azure-functions-nodejs-extensions/tree/main/azure-functions-nodejs-extensions-blob)
19+
20+
## License
21+
22+
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
23+
24+
## Resources
25+
26+
- [Azure Functions Documentation](https://learn.microsoft.com/azure/azure-functions/)
27+
- [Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)
28+
29+
---
30+
31+
## Reporting Issues
32+
33+
If you find a bug or have a suggestion for improvement, please [open an issue](https://github.com/Azure/azure-functions-nodejs-extensions/issues) on our GitHub repository.
Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,103 @@
1-
# To be created.
1+
## Azure Functions Node.js Extensions - Blob
2+
3+
This project provides extensions for working with Azure Blob Storage in Azure Functions using Node.js. It simplifies the integration and interaction with Blob Storage, enabling developers to build scalable and efficient serverless applications.
4+
5+
### Features
6+
7+
- **Blob Trigger**: Automatically trigger Azure Functions when a blob is created or updated in a specified container.
8+
- **Blob Input Binding**: Read blob content as input to your function.
9+
- **Cached Client Management**: Optimized client reuse with intelligent caching
10+
- **Resource Management**: Proper disposal patterns for Azure resource clients
11+
- **Performance Optimizations**: Reduced overhead for blob operations
12+
13+
### Prerequisites
14+
15+
- [Node.js](https://nodejs.org/) (LTS version recommended)
16+
- [Azure Functions Core Tools](https://learn.microsoft.com/azure/azure-functions/functions-run-local)
17+
- An active [Azure subscription](https://azure.microsoft.com/free/)
18+
19+
### Installation
20+
21+
To install the required dependencies, run:
22+
23+
```bash
24+
npm install @azure/functions-extensions-blob
25+
```
26+
27+
### Usage
28+
29+
1. **Set up your Azure Blob Storage account**:
30+
31+
- Create a storage account in the Azure portal.
32+
- Create a container within the storage account.
33+
34+
2. **Configure your function**:
35+
36+
- Update the `function.json` file to include the appropriate bindings for Blob Storage.
37+
38+
3. **Import and initialize the extension:**
39+
40+
```javascript
41+
import '@azure/functions-extensions-blob'; // Ensures at the top of the file
42+
```
43+
44+
Using in Azure Functions
45+
46+
```javascript
47+
import "@azure/functions-extensions-blob"; // Ensures side effects run
48+
import { StorageBlobClient } from "@azure/functions-extensions-blob";
49+
import { app, InvocationContext } from "@azure/functions";
50+
51+
export async function storageBlobTrigger1(
52+
blobStorageClient: StorageBlobClient,
53+
context: InvocationContext
54+
): Promise<void> {
55+
context.log(
56+
`Storage blob function processed blob "${context.triggerMetadata.name}"`
57+
);
58+
try {
59+
// Use the cached client for better performance
60+
const downloadBlockBlobResponse =
61+
await blobStorageClient.blobClient.download();
62+
// Additional operations...
63+
64+
}
65+
}
66+
67+
app.storageBlob("storageBlobTrigger1", {
68+
path: "snippets/SomeFolder/{name}",
69+
connection: "AzureWebJobsStorage",
70+
sdkBinding: true, //Ensure this is set to true
71+
handler: storageBlobTrigger1,
72+
});
73+
74+
75+
```
76+
77+
4. **Run locally**:
78+
79+
- Use the Azure Functions Core Tools to run your function locally:
80+
`bash
81+
func start
82+
`
83+
84+
4. **Deploy to Azure**:
85+
86+
- Deploy your function to Azure using the following command:
87+
`bash
88+
func azure functionapp publish <YourFunctionAppName>
89+
`
90+
91+
### Contributing
92+
93+
Contributions are welcome! Please follow the [contribution guidelines](CONTRIBUTING.md) when submitting issues or pull requests.
94+
95+
### License
96+
97+
This project is licensed under the [MIT License](LICENSE).
98+
99+
### Resources
100+
101+
- [Azure Functions Documentation](https://learn.microsoft.com/azure/azure-functions/)
102+
- [Azure Blob Storage Documentation](https://learn.microsoft.com/azure/storage/blobs/)
103+
- [Azure SDK for JavaScript](https://learn.microsoft.com/azure/javascript/)

0 commit comments

Comments
 (0)