Skip to content

Latest commit

 

History

History
104 lines (84 loc) · 3.4 KB

File metadata and controls

104 lines (84 loc) · 3.4 KB

Sample for Spring Cloud Azure Storage [Blob |File Share] 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 Spring Cloud Azure Storage Starter. 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>spring-cloud-azure-starter-storage-file-share</artifactId>
</dependency>

Gradle coordinates:

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

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
    spring:
      cloud:
        azure:
          storage:
            fileshare:
              account-name: [storage-account-name]
              account-key: [storage-account-access-key]
              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:
      file: [azure-file://[your-fileshareName]/[your-fileName]]  # [Optional] Required if you want to run FileController

How to run

  1. Start the StorageFileShareApplication 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' http://localhost:8080/file

    Verify by sending a GET request

    curl -XGET http://localhost:8080/file

    Verify in app’s log the messages was posted:

    new message
  3. Delete the resources on Azure Portal to avoid unexpected charges.

Examples

Troubleshooting

Contributing