Code Monkey home page Code Monkey logo

netappfiles-java-pool-change-sdk-sample's Introduction

page_type languages products description
sample
java
azure
azure-netapp-files
This project demonstrates how to perform a pool change on a Volume for Microsoft.NetApp resource provider using Java SDK.

Azure NetAppFiles SDK Sample - Pool Change for Java

This project demonstrates how to use a Java sample application to perform a pool change on a Volume for the Microsoft.NetApp resource provider.

In this sample application we perform the following operations:

  • Creations
    • ANF Account
    • Source Capacity Pool in service level Premium
    • Destination Capacity Pool in service level Standard
    • Volume in the Source pool
  • Updates
    • Perform pool change, moving Volume from Premium tier capacity pool to Standard tier capacity pool
  • Deletions
    • Volume
    • Source Capacity Pool
    • Destination Capacity Pool
    • ANF Account

Note: The cleanup execution is disabled by default. If you want to run this end to end with the cleanup, please change value of boolean variable 'cleanup' in main.java

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

Prerequisites

  1. 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
  2. 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. Instructions on setting JAVA_HOME can be found here for windows, and here for macOS.
  3. Azure subscription
  4. Subscription needs to have Azure NetApp Files resource provider registered. For more information, see Register for NetApp Resource Provider.
  5. Subscription needs to be enabled for Azure NetApp Files. For more information, please refer to this document.
  6. (Valid only while Pool Change feature is in preview state) Request preview access for Azure NetApp Files Pool Change. For more information, please refer to this document.
  7. Resource Group created
  8. Virtual Network with a delegated subnet to Microsoft.Netapp/volumes resource. For more information. please refer to Guidelines for Azure NetApp Files network planning
  9. For this sample console application to work we need to authenticate. We will be using Service Principal based 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. Set the following environment variables from the output of the creation:

      Powershell

      $env:AZURE_SUBSCRIPTION_ID = <subscriptionId>
      $env:AZURE_CLIENT_ID = <clientId>
      $env:AZURE_CLIENT_SECRET = <clientSecret>
      $env:AZURE_TENANT_ID = <tenantId>

      Bash

      export AZURE_SUBSCRIPTION_ID=<subscriptionId>
      export AZURE_CLIENT_ID=<clientId>
      export AZURE_CLIENT_SECRET=<clientSecret>
      export AZURE_TENANT_ID=<tenantId>

What is netappfiles-java-pool-change-sdk-sample doing?

This sample is dedicated to demonstrating how to perform a pool change on a Volume in Azure NetApp Files. Similar to other ANF SDK examples, the authentication method is based on a service principal. This project will first create an ANF Account and then two Capacity Pools, one at a Premium service level tier, and another at a Standard service level tier. Then it will create a single Volume in the Premium tier Capacity Pool. Finally, the sample will perform the pool change operation on the Volume by moving it to the Standard tier Capacity Pool.

There is a section in the code dedicated to remove created resources. By default this script will not remove all created resources; this behavior is controlled by a boolean variable called 'cleanup' in the main class. If you want to erase all resources right after the creation operations, set this variable to 'true'.

Note: This sample does not have a specific retrieve section since we perform get operations in several places throughout the code.

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\^ Cleanup.java Performs the delete operations of the created resources
Root\^ Creation.java Performs the creation operations of resources
Root\^ Update.java Performs the pool change operation
Root\^\common CommonSdk.java Class dedicated to common operations related to ANF's SDK
Root\^\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\^\common ServiceCredentialsAuth.java A small support class for extracting and creating credentials from a File
Root\^\common Utils.java Class that contains utility functions for writing output, retrieving AD password, etc.

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

How to run the console application

  1. Clone it locally
    git clone https://github.com/Azure-Samples/netappfiles-java-pool-change-sdk-sample
  2. Change folder to .\netappfiles-java-pool-change-sdk-sample
  3. Make sure you have the azureauth.json and its environment variable with the path to it defined (as previously described)
  4. Make sure the JAVA_HOME environment variable is pointing to version 11 of Java or newer (see Prerequisites for instructions)
  5. In the main.java class, change the values of the variables within the runAsync() function to reflect your environment
  6. Compile the console application
    mvn clean compile
  7. Run the console application
    mvn exec:java -Dexec.mainClass="poolchange.sdk.sample.main"

Sample output e2e execution

References

netappfiles-java-pool-change-sdk-sample's People

Contributors

adelghabboun avatar haukurstefansson avatar hildurhodd avatar microsoft-github-operations[bot] avatar microsoftopensource avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netappfiles-java-pool-change-sdk-sample's Issues

ACTION REQUIRED: Microsoft needs this private repository to complete compliance info

There are open compliance tasks that need to be reviewed for your netappfiles-java-pool-change-sdk-sample repo.

Action required: 4 compliance tasks

To bring this repository to the standard required for 2021, we require administrators of this and all Microsoft GitHub repositories to complete a small set of tasks within the next 60 days. This is critical work to ensure the compliance and security of your Azure-Samples GitHub organization.

Please take a few minutes to complete the tasks at: https://repos.opensource.microsoft.com/orgs/Azure-Samples/repos/netappfiles-java-pool-change-sdk-sample/compliance

  • The GitHub AE (GitHub inside Microsoft) migration survey has not been completed for this private repository
  • No Service Tree mapping has been set for this repo. If this team does not use Service Tree, they can also opt-out of providing Service Tree data in the Compliance tab.
  • No repository maintainers are set. The Open Source Maintainers are the decision-makers and actionable owners of the repository, irrespective of administrator permission grants on GitHub.
  • Classification of the repository as production/non-production is missing in the Compliance tab.

You can close this work item once you have completed the compliance tasks, or it will automatically close within a day of taking action.

If you no longer need this repository, it might be quickest to delete the repo, too.

GitHub inside Microsoft program information

More information about GitHub inside Microsoft and the new GitHub AE product can be found at https://aka.ms/gim.

FYI: current admins at Microsoft include @AdelGhabboun, @leonardbf, @haukurstefansson, @shanemkm, @Phil-Jensen, @paulomarquesc, @lichunli-ms, @audunn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.