Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Sample for Azure Spring Boot Storage starter library for Java

Key concepts

This code sample demonstrates how to read and write files with the Spring Resource abstraction for Azure Storage using the Azure Spring Boot Starter Storage. Running this sample will be charged by Azure. You can check the usage and bill at this link.

Getting started

Coordinates

Maven coordinates:

<dependency>
    <groupId>com.azure.spring</groupId>
    <artifactId>azure-spring-boot-starter-storage</artifactId>
</dependency>

Gradle coordinates:

dependencies {
    compile group: 'com.azure.spring', name: 'azure-spring-boot-starter-storage'
}

Configure the application.properties

  1. Create Azure Storage

  2. Update {application.yml}[application.yml]

    # Storage account name length should be between 3 and 24 and use numbers and lower-case letters only
    # Configuration
    azure.storage:
      account-name: [storage-account-name]
      account-key: [storage-account-access-key]
      blob-endpoint: [Fill storage Blob service endpoint URL copied from portal] # [Optional] Required if you want to run BlobController
      file-endpoint: [Fill storage File service endpoint URL copied from portal] # [Optional] Required if you want to run FileController
    
    # Resource location, used in this sample
    resource:
      blob: [azure-blob://[your-containerName]/[your-blobName]]  # [Optional] Required if you want to run BlobController
      file: [azure-file://[your-fileshareName]/[your-fileName]]  # [Optional] Required if you want to run FileController

How to run

  1. Start the StorageApplication Spring Boot app.

    $ mvn spring-boot:run
  2. Send a POST request to update file contents:

    $ curl -d 'new message' -H 'Content-Type: text/plain' localhost:8080/blob

    Verify by sending a GET request

    $ curl -XGET http://localhost:8080/blob
  3. Delete the resources on Azure Portal to avoid unexpected charges.

Examples

Troubleshooting

Contributing