You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next, you walk through the sample code to understand how it works.
132
132
133
+
### Inject a client object with authorized access
134
+
135
+
Working with any Azure resource using the SDK begins with creating a client object. The Quarkus extension for Azure Blob Storage automatically injects a client object with authorized access using `DefaultAzureCredential`.
136
+
137
+
To successfully inject a client object, first you need to add the extension `quarkus-azure-storage-blob` to your `pom.xml` file as a dependency:
Next, you can inject the client object into your application code using the `@Inject` annotation:
148
+
149
+
```java
150
+
@Inject
151
+
BlobServiceClient blobServiceClient;
152
+
```
153
+
154
+
This is all you need to code to get a client object using the Quarkus extension for Azure Blob Storage. To make sure the client object is authorized to access your storage account at runtime, you need to follow steps in the previous section [Authenticate to Azure and authorize access to blob data](#authenticate-to-azure-and-authorize-access-to-blob-data) before running the application.
155
+
156
+
### Manage blobs and containers
157
+
158
+
The following code snippet shows how to create a container, upload a blob, list blobs in a container, and download a blob:
System.out.println("\nPress the Enter key to begin clean up");
214
+
System.console().readLine();
215
+
216
+
System.out.println("Deleting blob container...");
217
+
blobContainerClient.delete();
218
+
219
+
System.out.println("Deleting the local source and downloaded files...");
220
+
localFile.delete();
221
+
downloadedFile.delete();
222
+
223
+
System.out.println("Done");
224
+
```
225
+
226
+
These operations are similar to the [Quickstart: Azure Blob Storage client library for Java](storage-quickstart-blobs-java.md). For more detailed code explanations, see the following sections in that quickstart:
227
+
228
+
-[Create a container](storage-quickstart-blobs-java.md#create-a-container)
229
+
-[Upload blobs to a container](storage-quickstart-blobs-java.md#upload-blobs-to-a-container)
230
+
-[List blobs in a container](storage-quickstart-blobs-java.md#list-blobs-in-a-container)
0 commit comments