Java中的Azure应用程序功能可从Azure存储帐户查看Blob文件列表

时间:2018-09-10 07:56:17

标签: java azure cloud azure-functions azure-blob-storage

这是我从blob中提取所有jpg文件的代码:

import com.microsoft.azure.functions.annotation.*;
import com.microsoft.azure.functions.*;
public class Function {
@FunctionName("blobprocessor")
@StorageAccount("AzureWebJobsStorage")
 public void run(
    @BlobTrigger(name = "content",
                  dataType = "binary",
                  path ="=imagescontainer/{name}.jpg") byte[] content,
    @BindingName("myBlob") String name,
     final ExecutionContext context
 )
 {
context.getLogger().info("Name: " + name + " Size: " + content.length + "             
 bytes");
    }
   }



local.settings.json` file

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": 

“ DefaultEndpointsProtocol = https; AccountName = account-name; AccountKey = account-key; EndpointSuffix = core.windows.net”,         “ AzureWebJobsDashboard”:“ DefaultEndpointsProtocol = https; AccountName =帐户名称; AccountKey =帐户密钥; EndpointSuffix = core.windows.net”,         “ FUNCTIONS_WORKER_RUNTIME”:“ java8”,         “ FUNCTIONS_EXTENSION_VERSION”:“〜2”       }     }

 I am trying to list all the jpg files from a container using the above 
 code. I am trying to run this locally before deploying on it azure app 
 functions but it is not working. Please help me.

 When I run "mvn azure-functions:run


 [9/10/2018 9:19:53 AM] Initializing Host.
 [9/10/2018 9:19:53 AM] Host initialization: ConsecutiveErrors=0, 
 StartupCount=1
 [9/10/2018 9:19:53 AM] Starting JobHost
 [9/10/2018 9:19:53 AM] Starting Host (HostId=rveeresh01-1999346529, 
 InstanceId=64beeb74-e930-46cc-b380-0a8fa316ccc7, Version=2.0.12050.0, 
 ProcessId=19228, AppDomainId=1, Debug=False, 
 FunctionsExtensionVersion=~2)
 [9/10/2018 9:19:54 AM] Generating 0 job function(s)
 [9/10/2018 9:19:54 AM] No job functions found. Try making your job 
 classes and methods public. If you're using binding extensions (e.g. 
 ServiceBus, Timers, etc.) make sure you've called the registration method 
 for the extension(s) in your startup code (e.g. config.UseServiceBus(), 
 config.UseTimers(), etc.).
 [9/10/2018 9:19:54 AM] Host initialized (197ms)
 [9/10/2018 9:19:54 AM] Host started (211ms)
 [9/10/2018 9:19:54 AM] Job host started
 Now listening on: http://0.0.0.0:7071
 Application started. Press Ctrl+C to shut down.
 Listening on http://0.0.0.0:7071/
 Hit CTRL-C to exit...
 [9/10/2018 9:20:01 AM] Host lock lease acquired by instance ID  
'000000000000000000000000215C11A1'.

1 个答案:

答案 0 :(得分:1)

请将“ FUNCTIONS_WORKER_RUNTIME”设置为“ java”而不是Java8