11package com .microsoft .azure .functions .endtoend ;
22
3+ import com .azure .storage .blob .BlobClientBuilder ;
34import com .microsoft .azure .functions .annotation .*;
45
6+ import java .io .ByteArrayInputStream ;
57import java .io .ByteArrayOutputStream ;
6- import java .util .List ;
7- import java .util .Optional ;
88
99import com .microsoft .azure .functions .*;
1010
@@ -69,7 +69,6 @@ public void BlobTriggerStringTest(
6969 public void BlobTriggerToBlobTest_BlobClient (
7070 @ BlobTrigger (name = "triggerBlob" , path = "test-triggerinput-blobclient/{name}" , dataType = "binary" ) BlobClient triggerBlobClient ,
7171 @ BindingName ("name" ) String fileName ,
72- @ BlobOutput (name = "outputBlob" , path = "test-output-java-new/{name}" , dataType = "binary" ) OutputBinding <byte []> outputBlob ,
7372 final ExecutionContext context
7473 ) {
7574 context .getLogger ().info ("BlobTriggerUsingBlobClient triggered for blob: " + fileName );
@@ -78,9 +77,21 @@ public void BlobTriggerToBlobTest_BlobClient(
7877 ByteArrayOutputStream outputStream = new ByteArrayOutputStream ();
7978 triggerBlobClient .downloadStream (outputStream );
8079
81- // Set the downloaded content as output
82- outputBlob .setValue (outputStream .toByteArray ());
83- context .getLogger ().info ("Blob content copied successfully from trigger blob to output blob." );
80+ // Get connection string from environment variable
81+ String connectionString = System .getenv ("AzureWebJobsStorage" );
82+
83+ // Define the BlobClient for the destination blob
84+ BlobClient outputBlobClient = new BlobClientBuilder ()
85+ .connectionString (connectionString )
86+ .containerName ("test-output-java-new" )
87+ .blobName (fileName )
88+ .buildClient ();
89+
90+ // Upload the blob content to the destination container
91+ byte [] data = outputStream .toByteArray ();
92+ outputBlobClient .upload (new ByteArrayInputStream (data ), data .length , true );
93+
94+ context .getLogger ().info ("Uploaded blob " + fileName + " to container test-output-java-new" );
8495 }
8596
8697 /**
@@ -91,7 +102,6 @@ public void BlobTriggerToBlobTest_BlobClient(
91102 public void BlobTriggerToBlobTest_BlobContainerClient (
92103 @ BlobTrigger (name = "triggerBlob" , path = "test-triggerinput-blobcontclient/{name}" , dataType = "binary" ) BlobContainerClient triggerBlobContainerClient ,
93104 @ BindingName ("name" ) String fileName ,
94- @ BlobOutput (name = "outputBlob" , path = "test-output-java-new/{name}" , dataType = "binary" ) OutputBinding <byte []> outputBlob ,
95105 final ExecutionContext context
96106 ) {
97107 context .getLogger ().info ("BlobTriggerUsingBlobContainerClient triggered for blob: " + fileName );
@@ -101,9 +111,21 @@ public void BlobTriggerToBlobTest_BlobContainerClient(
101111 ByteArrayOutputStream outputStream = new ByteArrayOutputStream ();
102112 triggerBlobClient .downloadStream (outputStream );
103113
104- // Set the downloaded content as output
105- outputBlob .setValue (outputStream .toByteArray ());
106- context .getLogger ().info ("Blob content copied successfully from trigger blob to output blob." );
114+ // Get connection string from environment variable
115+ String connectionString = System .getenv ("AzureWebJobsStorage" );
116+
117+ // Define the BlobClient for the destination blob
118+ BlobClient outputBlobClient = new BlobClientBuilder ()
119+ .connectionString (connectionString )
120+ .containerName ("test-output-java-new" )
121+ .blobName (fileName )
122+ .buildClient ();
123+
124+ // Upload the blob content to the destination container
125+ byte [] data = outputStream .toByteArray ();
126+ outputBlobClient .upload (new ByteArrayInputStream (data ), data .length , true );
127+
128+ context .getLogger ().info ("Uploaded blob " + fileName + " to container test-output-java-new" );
107129 }
108130
109131 public static class TestBlobData {
0 commit comments