Skip to content

This projects aims to build ANF Cross-Region Replication using Java SDK

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

hildurhodd/netappfiles-java-crr-sdk-sample

 
 
page_type languages products description
sample
java
azure
azure-netapp-files
This project demonstrates how to use Java with NetApp Files SDK for Microsoft.NetApp resource provider to enable cross-region replication on NFS 4.1 Volume.

Azure NetAppFiles Cross-Region Replication (CRR) SDK NFS 4.1 Sample Java

This project demonstrates how to deploy a volume based on NFSv4.1 protocol with cross-region replication enabled using Java and Azure NetApp Files SDK.

In this sample application we perform the following operations:

  • Creation

    • Primary ANF Account | Primary Capacity pool | Primary NFS v4.1 Volume
  • Secondary ANF Account | Secondary Capacity pool | Secondary NFS v.1 Data Protection Volume with referencing to the primary volume Resource ID

  • Authorize Primary volume with Secondary Volume Resource ID

If you don't already have a Microsoft Azure subscription, you can get a FREE trial account here.

Prerequisites

  1. Azure Subscription
  2. Subscription needs to be enabled for Azure NetApp Files. For more information, please refer to this document.
  3. Request preview access for Azure NetApp Files cross-region replication. For more information, please refer to this document.
  4. This project is built upon Maven, which has to be installed in order to run the sample. Instructions on installing Maven can be found on their website here.
  5. The sample is written in Java 11. The Maven compiler's target Java version is therefore Java 11, and the JAVA_HOME environment variable must be set to Java 11 or a newer version.
  6. Resource Group created.
  7. Virtual Network with a delegated subnet to Microsoft.Netapp/volumes resource. For more information, please refer to Guidelines for Azure NetApp Files network planning
  8. For this sample console appplication work, we are using service principal based authenticate, follow these steps in order to setup authentication:
    1. Within an Azure Cloud Shell session, make sure you're logged on at the subscription where you want to be associated with the service principal by default:

      az account show

      If this is not the correct subscription, use

      az account set -s <subscription name or id>  
    2. Create a service principal using Azure CLI

      az ad sp create-for-rbac --sdk-auth

      Note: this command will automatically assign RBAC contributor role to the service principal at subscription level, you can narrow down the scope to the specific resource group where your tests will create the resources.

    3. Copy the output content and paste it in a file called azureauth.json, secure it with file system permissions and save it outside the tree related of your local git repo folder so the file doesn't get commited.

    4. Set an environment variable pointing to the file path you just created, here is an example with Powershell and bash: Powershell

      [Environment]::SetEnvironmentVariable("AZURE_AUTH_LOCATION", "C:\sdksample\azureauth.json", "User")

      Bash

      export AZURE_AUTH_LOCATION=/sdksamples/azureauth.json

What is anf-java-crr-sdk-nfs4.1-sample.dll doing?

This sample project is dedicated to demonstrate how to enable cross-region replication in Azure NetApp Files for an NFSv4.1 enabled volume, similar to other examples, the authentication method is based on a service principal, this project will create two ANF Accounts in different regions with capacity pool. A single volume using Premium service level tier in the Primary ANF, and Data Protection Volume with Standard service level tier in the secondary region.

Note: The cleanup execution is disabled by default. If you want to run this end to end with the cleanup, please

  • mvn install>change value of boolean variable 'shouldCleanUp' in main.java

How the project is structured

The following table describes all files within this solution:

Folder FileName Description
Root\^ main.java Reads configuration, authenticates, executes all operations
Root\^ Creation.java Class that contains all resource creation loops, following the hierarchy logic in order to successfully deploy Azure NetApp Files resources
Root\^ Cleanup.java Class that performs cleanup of all artifacts that were created during this sample application. It's called when the variable shouldCleanUp in the main class is enabled
Root\^\nfs.sdk.sample.common CommonSdk.java Class dedicated to nfs.sdk.sample.common operations related to ANF's SDK
Root\^\nfs.sdk.sample.common ResourceUriUtils.java Class that exposes a few methods that help parsing Uri's, building new Uri's, or getting a resource name from a Uri, etc
Root\^\nfs.sdk.sample.common ServiceCredentialsAuth.java A small support class for extracting and creating credentials from a File
Root\^\nfs.sdk.sample.common Utils.java Class that exposes methods that help with getting the configuration object, byte conversion, etc
Root\^\model AzureAuthInfo.java POJO class to hold authentication information

\^ == src/main/java/sdk/sample |

How to run the console application

  1. Clone it locally
    git clone https://github.com/Azure-Samples/netappfiles-java-nfs4.1-sdk-sample.git
  2. Make sure you change the variables located at .netappfiles-java-crr-sdk-sample\src\main\main.java at RunAsync method.
  3. Change folder to .\anf-java-crr-sdk-sample
  4. Since we're using service principal authentication flow, make sure you have the azureauth.json and its environment variable with the path to it defined (as previously described)
  5. Compile the console application
    mvn clean compile
  6. Run the console application
    mvn exec:java -Dexec.mainClass="sdk.sample.main"
    

Sample output e2e execution

References

About

This projects aims to build ANF Cross-Region Replication using Java SDK

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.md

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%