Skip to content

b-hchen/netappfiles-powershell-nfs-script-sample

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
page_type languages products description
sample
powershell
azure
azure-netapp-files
This project demonstrates how to use Powershell with NetApp Files SDK for Microsoft.NetApp resource provider to deploy NFSv3 or NFSv4.1 Volume.

Azure NetAppFiles SDK NFSv3/NFS4.1 Sample Powershell

This project demonstrates how to deploy NFSv3/NFSv4.1 protocol type volume using Powershell and Azure NetApp Files SDK.

In this sample application we perform the following operations:

  • Creation

    • ANF Account
    • Capacity pool
    • NFS Volume
  • Deletion, the clean up process takes place (not enabled by default, please set the parameter CleanupResources to $true if you want the clean up code to take a place),deleting all resources in the reverse order following the hierarchy otherwise we can't remove resources that have nested resources still live.

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. Resource Group created
  4. Virtual Network with a delegated subnet to Microsoft.Netapp/volumes resource. For more information, please refer to Guidelines for Azure NetApp Files network planning
  5. Azure PowerShell, please refer to Install Azure PowerShell
  6. Run the following PS command:
    • Install-Module Az.NetAppFiles

How the project is structured

The following table describes all files within this solution:

Folder FileName Description
src CreateANFVolume.ps Authenticates and executes all operations
src\Common CommonSDK.psm1 PowerShell module that exposes some functions to perform creation and deletion Azure NetApp Files resource that calls the actual Az.NetAppFiles cmdlets
src\Common Utils.psm1 Static class that exposes a few methods that helps on various tasks, like writting a log to the console for example.
src\Common AzureAuth.psm1 PoweShell module that exposes functions to connect to Azure and choose target subscription

How to run the PowerShell script

  1. Clone it locally

    git clone https://github.com/Azure-Samples/netappfiles-powershell-nfs-sdk-sample.git
  2. Modes: There are two options to run the script

    Basic mode - Single script create Azure NetApp files with no validation.

    • Change folder to netappfiles-powershell-nfs-sdk-sample\src\Basic
    • Open CreateANFVolume and edit all the parameters
    • Save and close
    • Run the following command
    CreateANFVolume.ps1

    Sample output e2e execution

    OR

    Advanced mode - More advanced way to run the script to create Azure Netapp Files with validation using modules

    • Change folder to netappfiles-powershell-nfs-sdk-sample\src\Advanced
    • Change values bewtween brackets [ ] below and then run the command
    CreateANFVolume.ps1 -SubscriptionId '[subscriptionId]' -ResourceGroupName '[Azure Resource Group Name]' -Location '[Azure Location]' -NetAppAccountName '[ANF Account Name]' -NetAppPoolName '[ANF Capacity Pool Name]' -ServiceLevel [Ultra,Premium, Standard] -NetAppVolumeName '[ANF Volume Name]' -ProtocolType [NFSv3,NFSv4.1] -SubnetId '[Subnet ID]'

    Note: The below table shows all the mandatory and optional parameters

    Parameter Mandatory Default Value
    -SubscriptionId Yes
    -ResourceGroupName Yes
    -Location Yes
    -NetAppAccountName Yes
    -NetAppPoolName Yes
    -ServiceLevel Yes
    -NetAppPoolSize No 4398046511104
    -NetAppVolumeName Yes
    -ProtocolType Yes
    -NetAppVolumeSize No 107374182400
    -SubnetId Yes
    -EPUnixReadOnly No False
    -EPUnixReadWrite No True
    -AllowedClientsIp No 0.0.0.0/0
    -CleanupResources No False

    Sample output e2e execution

Troubleshoot

If you encounter the below issue when running the PoweShell command

.\CreateANFVolume.ps1 : .\CreateANFVolume.ps1 cannot be loaded. The file .\CreateANFVolume.ps1 is not digitally signed. You cannot 
run this script on the current system.

Run the following command Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass

References

About

This project aims to create Azure NetApp Files with NFS protocol type volume

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PowerShell 100.0%