Skip to content

Files

Latest commit

e3084e7 · Jul 14, 2020

History

History
This branch is 425 commits behind microsoft/spring-cloud-azure:main.

storage-queue-integration-sample

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Mar 19, 2020
Jan 9, 2019
Jul 14, 2020

Spring Cloud Azure Storage Queue Integration Code Sample

This code sample demonstrates how to use Spring Integration for Azure Storage Queue.

Running this sample will be charged by Azure. You can check the usage and bill at this link.

Access key based usage

  1. Create Azure Storage

  2. Update application.properties

    spring.cloud.azure.storage.account=[storage-account-name]
    
    # Fill storage account access key copied from portal
    spring.cloud.azure.storage.access-key=[storage-account-accesskey]

Credential file based usage

  1. Create azure credential file. Please see how to create credential file.

    $  az login
    $  az account set --subscription <name or id>
    $  az ad sp create-for-rbac --sdk-auth > my.azureauth

    Make sure my.azureauth is encoded with UTF-8.

  2. Put credential file under src/main/resources/.

  3. Create Azure Storage. Or enable auto create resources feature in application.properties:

    spring.cloud.azure.auto-create-resources=true
    
    # Example region is westUS, northchina
    spring.cloud.azure.region=[region]
  4. Update application.properties

    # Enter 'my.azureauth' here if following step 1 and 2
    spring.cloud.azure.credential-file-path=[credential-file-path]
    
    spring.cloud.azure.resource-group=[resource-group]
    
    spring.cloud.azure.storage.account=[account-name]

How to run

  1. Update environment if not is Global in application.properties

    # Default environment is GLOBAL. Provide your own if in another environment
    # Example environment is China, GLOBAL
    # spring.cloud.azure.environment=[environment]
  2. Update queue name in SendController and ReceiveController

  3. Run the mvn clean spring-boot:run in the root of the code sample to get the app running.

  4. Send a POST request

    $ curl -X POST localhost:8080/messages?message=hello
  5. Verify in your app’s logs that a similar message was posted:

    New message received: 'hello'
    Message 'hello' successfully checkpointed
  6. Delete the resources on Azure Portal to avoid unexpected charges.