| page_type | languages | products | description | |||
|---|---|---|---|---|---|---|
sample |
|
|
This project demonstrates how to use Powershell with NetApp Files SDK for Microsoft.NetApp resource provider to deploy NFSv3 or NFSv4.1 Volume. |
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.
- Azure Subscription
- Subscription needs to be enabled for Azure NetApp Files. For more information, please refer to this document.
- Resource Group created
- Virtual Network with a delegated subnet to Microsoft.Netapp/volumes resource. For more information, please refer to Guidelines for Azure NetApp Files network planning
- Azure PowerShell, please refer to Install Azure PowerShell
- Run the following PS command:
- Install-Module Az.NetAppFiles
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 |
-
Clone it locally
git clone https://github.com/Azure-Samples/netappfiles-powershell-nfs-sdk-sample.git
-
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
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
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