How can i use blob storage from an azure function in Java

How can i use blob storage from an azure function in Java

By : Haohao Lou
Date : November 22 2020, 03:01 PM
wish helps you According to your needs,I suggest you following this official tutorial to create,run and deploy your java azure function.
Function Class:
code :
package com.fabrikam.functions;

import com.microsoft.azure.serverless.functions.annotation.*;
import com.microsoft.azure.serverless.functions.ExecutionContext;

import com.microsoft.azure.storage.*;
import com.microsoft.azure.storage.blob.*;

 * Hello function with HTTP Trigger.
public class Function {

    // Configure the connection-string with your values
    public static final String storageConnectionString =
            "DefaultEndpointsProtocol=http;" +
                    "AccountName=***;" +

    public String hello(@HttpTrigger(name = "req", methods = {"get", "post"}, authLevel = AuthorizationLevel.ANONYMOUS) String req,
                        ExecutionContext context) {

        try {
            // Retrieve storage account from connection-string.
            CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);

            // Create the blob client.
            CloudBlobClient blobClient = storageAccount.createCloudBlobClient();

            // Get a reference to a container.
            // The container name must be lower case
            CloudBlobContainer container = blobClient.getContainerReference(req);

            // Create the container if it does not exist.

            return String.format("Hello, I get container name : %s!", container.getName());

        } catch (Exception e) {
            // Output the stack trace.
            return "Access Error!";
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


    <name>Azure Java Functions</name>



        <!-- https://mvnrepository.com/artifact/com.microsoft.azure/azure-storage -->

        <!-- Test -->




Stack: java.lang.reflect.InvocationTargetException
[10/25/2017 2:48:44 AM]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[10/25/2017 2:48:44 AM]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[10/25/2017 2:48:44 AM]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[10/25/2017 2:48:44 AM]         at java.lang.reflect.Method.invoke(Method.java:498)
[10/25/2017 2:48:44 AM]         at com.microsoft.azure.webjobs.script.broker.JavaMethodInvokeInfo.invoke(JavaMethodInvokeInfo.java:19)
[10/25/2017 2:48:44 AM]         at com.microsoft.azure.webjobs.script.broker.JavaMethodExecutor.execute(JavaMethodExecutor.java:34)
[10/25/2017 2:48:44 AM]         at com.microsoft.azure.webjobs.script.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:40)
[10/25/2017 2:48:44 AM]         at com.microsoft.azure.webjobs.script.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33)
[10/25/2017 2:48:44 AM]         at com.microsoft.azure.webjobs.script.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
[10/25/2017 2:48:44 AM]         at com.microsoft.azure.webjobs.script.handler.MessageHandler.handle(MessageHandler.java:41)
[10/25/2017 2:48:44 AM]         at com.microsoft.azure.webjobs.script.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:84)
[10/25/2017 2:48:44 AM]         at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
[10/25/2017 2:48:44 AM]         at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
[10/25/2017 2:48:44 AM]         at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
[10/25/2017 2:48:44 AM]         at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
[10/25/2017 2:48:44 AM]         at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
[10/25/2017 2:48:44 AM] Caused by: java.lang.NoClassDefFoundError: com/microsoft/azure/storage/CloudStorageAccount
[10/25/2017 2:48:44 AM]         at com.fabrikam.functions.Function.hello(Function.java:26)
[10/25/2017 2:48:44 AM]         ... 16 more
[10/25/2017 2:48:44 AM] Caused by: java.lang.ClassNotFoundException: com.microsoft.azure.storage.CloudStorageAccount
[10/25/2017 2:48:44 AM]         at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
[10/25/2017 2:48:44 AM]         at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[10/25/2017 2:48:44 AM]         at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[10/25/2017 2:48:44 AM]         ... 17 more
[10/25/2017 2:48:44 AM] .
[10/25/2017 2:48:44 AM]   Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is '3450abda-99a0-4d75-add2-a7bc48a0cb51'
[10/25/2017 2:48:44 AM] System.Private.CoreLib: Exception while executing function: Functions.hello. System.Private.CoreLib: Result:
                            <mainClass>Your main class path</mainClass>

Share : facebook icon twitter icon
How to dynamically set blob name to store in Blob storage in azure function nodejs?

How to dynamically set blob name to store in Blob storage in azure function nodejs?

By : user2071823
Date : March 29 2020, 07:55 AM
This might help you Find one workaround, see whether it's useful.
Along with blob output binding, there's an activity trigger to receive message msg, we can put self-defined blob name in msg for blob binding path to consume.
code :
yield context.df.callActivity("YourActivity", {'body':'messagecontent','blobName':'myblob'});
context.bindings.myOutputBlob = context.bindings.msg.body;
  "bindings": [
      "name": "msg",
      "type": "activityTrigger",
      "direction": "in"
      "direction": "out",
      "type": "blob",
      "connection": "AzureWebJobsStorage",
      "path": "azureblob/{blobName}"
  "disabled": false
Azure Blob Storage - Retrieve user that reads or writes blob in Storage Container

Azure Blob Storage - Retrieve user that reads or writes blob in Storage Container

By : user2718905
Date : March 29 2020, 07:55 AM
will be helpful for those in need Unfortunately it's not an option in the current logs that are generated, they aren't fine grained yet(will be better on a newer release). the current log format would only indicate whether the request was authenticated or not,
This is an example of logs 2.0 for azure storage:
code :
1.0;2014-06-19T01:33:54.0926521Z;PutBlob;Success;201;197;54;authenticated;storagesample;storagesample;blob;"https://storagesample.blob.core.windows.net/sample-container1/00001.txt";"/storagesample/sample-container1/00001.txt";a200be85-1c98-4dd9-918e-f13d8c0538e0;0;;2014-02-14;460;23;225;0;23;"DrPO6z1f00SCsomhaf+J/A==";"DrPO6z1f00SCsomhaf+J/A==";""0x8D15975AA456EA4"";Thursday, 19-Jun-14 01:33:53 GMT;;"WA-Storage/4.0.1 (.NET CLR 4.0.30319.34014; Win32NT 6.3.9600.0)";;"1fe6814a-e4cb-4195-a3cf-837dc7120f68"
Can I change the output binding from BLOB storage to File sharing storage in Azure function?

Can I change the output binding from BLOB storage to File sharing storage in Azure function?

By : user3115046
Date : March 29 2020, 07:55 AM
To fix this issue As far as I know, currently Azure function doesn't support Azure File share output binding. You may refer to this tutorial: https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#binding-direction
But you can also use Azure File storage sdk to do that, I post some code below for your reference:
code :
var storageAccount = CloudStorageAccount.Parse("your connection string");
var fileClient = storageAccount.CreateCloudFileClient();
string baseShareName = "myazurefileshare";
var share = fileClient.GetShareReference(baseShareName);
var rootDir = share.GetRootDirectoryReference();  
var sampleDir = rootDir.GetDirectoryReference("MyFolder");
var fileToCreate = sampleDir.GetFileReference("output.txt");
Azure Blob Storage - MVC Web Application - Is there a way to upload directly into Azure Blob Storage without going throu

Azure Blob Storage - MVC Web Application - Is there a way to upload directly into Azure Blob Storage without going throu

By : Portal Marketing Ind
Date : March 29 2020, 07:55 AM
around this issue At this time it's not possible because Windows Azure Storage does not have CORS support. However during a presentation at \Build conference storage team indicated that it is coming. One way to achieve this is by hosting the HTML page for upload in that storage account only as mentioned in the link by @viperguyz and use SAS for uploading blobs in that storage account. If you want, you could map a custom domain to your blob storage account and use that domain name. The problem with custom domain name is that you won't be able to use SSL.
Difference between Azure Data Lake Storage x Azure Blob Storage and Azure File Storage

Difference between Azure Data Lake Storage x Azure Blob Storage and Azure File Storage

By : J.moths
Date : March 29 2020, 07:55 AM
With these it helps You can take a look at this article: https://docs.microsoft.com/en-us/azure/data-lake-store/data-lake-store-comparison-with-blob-storage
I'd say main differences between Data Lake and Azure Storage Blob is scale and permissions model.
Related Posts Related Posts :
  • SpringBoot : No matching bean found exception
  • Implementing the Clonable interface, but don't have to override the clone() method
  • how can i get this code to choose a random word once from each array to print a sentence?
  • Static class to get connections from connection pool
  • Unable to start Chrome browser with user profile in Selenium
  • How to pass a object to be created as a parameter for a method in Java?
  • How to retry with hystrix
  • Loading key to KeyStore fails on Android Oreo
  • Spring+Velocity unsuccessful attempts to save object
  • Private constructor in Kotlin
  • Jetty:run fails with NoSuchMethodError with Spring 5
  • Cannot upload my Web Applicartion in Jboss7 EAP7 EAP
  • How to load a certificate from "Credential storage"?
  • Call Genexus procedure stub in Java environment
  • JavaFX clipping produces a 'lottery scratch ticket'-Effect
  • Using DateTimeFormatter on january first cause an invalid year value
  • Get all the output from Watson conversation using java
  • Java unable to open main class and jar file
  • How to override @override method from activity into another class
  • Adding Runtime VM parameters to intellij for Java 9
  • Java IBM MQ Client connected but not getting messages from queue
  • Questions of Tomcat SSL configuration
  • Stale JNLP files for <extension> (since Java 9?)
  • Properly set (system) properties in JUnit 5
  • Spring MVC Model within POST Method is empty
  • VSTS buildagent: Java 9
  • java.lang.NumberFormatException: For input string: "id" for Hibernate
  • Query id return type
  • Pass variable in API url in java .
  • Reading semicolon delimited csv
  • Get the workspace root
  • Native mmap error
  • hashmap and multiple txt files java
  • Kotlin: Access nested enum class from java
  • Google RateLimiter not Working for counter
  • Spring Boot Application Hanging When Running on Command Line
  • large amount of if else refactor
  • Unable to add xmlunit as dependancy in my pom
  • Scanner input needed twice, when only wanted once
  • How to interpret and translate kotlin code to java?
  • Firebase authentication: signInWithEmailAndPassword method dont respond at all
  • How Remove Recycler Separator/divider programmatically or using xml property
  • Not Able to Save Data Hibernate
  • Toolbar addView not working
  • Freeing memory wrapped with NewDirectByteBuffer
  • Synchronization with implicitwait() do not work, why?
  • Wrapper around Java primitive types
  • ClassNotFoundException: spark.Request when running from command line
  • Exception in Hibernate Configuration
  • How can I validate XML embedded in JSON using Citrus framework?
  • How is the String value passed to the updateText() method?
  • Memory efficient replace functions
  • Upload Photo with onActivityResult, but without Fullscreen capturing
  • Docker: Java 8 installation failing on Ubuntu
  • Java Netbeans Calculator performing wrong calculation
  • Nifi: Threads in nifi
  • While loop Int return inside the method completely dead
  • Checking if a user's entry is an integer using try catch statements
  • Forcing a subclass to provide an initialization method
  • calling a fuction and variables from another class in java
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org