| 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 a volume with the NFSv3/NFSv4.1 protocol type by 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, deleting all resources in the reverse order following the hierarchy. You cannot remove resources that have nested resources still live.Note that the clean-up operation is not enabled by default. You need to set the parameter CleanupResources to $true for the clean-up code to take effect.
If you don't already have a Microsoft Azure subscription, you can get a FREE trial account here.
- Azure Subscription.
- Subscription needs to have Azure NetApp Files resource provider registered. For more information, see Register for NetApp Resource Provider.
- Resource Group must be created.
- Virtual Network with a delegated subnet to Microsoft.Netapp/volumes resource. For more information, see Guidelines for Azure NetApp Files network planning.
- Azure PowerShell. See 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 of Azure NetApp Files resource that calls the actual Az.NetAppFiles cmdlets |
| src\Common | Utils.psm1 | Static class that exposes a few methods that are helpful for various tasks, such as writing a log to the console for example. |
| src\Common | AzureAuth.psm1 | PoweShell module that exposes functions to connect to Azure and choose the target subscription |
-
Clone the repository locally:
git clone https://github.com/Azure-Samples/netappfiles-powershell-nfs-sdk-sample.git
-
Use the basic mode or the advanced mode. 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 following 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