GithubHelp home page GithubHelp logo

lrakai / automate-azure-file-sync Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 1.0 41 KB

Demonstrate how to automate Azure File Sync deployments using PowerShell

License: MIT License

PowerShell 100.00%
azure-file-sync powershell-scripts automation

automate-azure-file-sync's Introduction

automate-azure-file-sync

Demonstrate how to automate Azure File Sync deployments using PowerShell. This Lab automates the tasks performed manually in Azure Portal and over RDP on the Windows Server in this Lab.

Final Environment

Getting Started

An Azure RM template is included in infrastructure/ to create the environment:

Using Azure PowerShell, do the following to provision the resources:

.\New-Lab.ps1

Alternatively, you can perform a one-click deploy with the following button:

Following Along

  1. Start an Azure Cloud Shell PowerShell.

  2. Create a file share:

    $fileShareName = "sync"
    $resourceGroupName = Get-AzResourceGroup | select -ExpandProperty ResourceGroupName
    $storageAccount = Get-AzStorageAccount -ResourceGroupName $resourceGroupName | `
                  where StorageAccountName -like calabsync*
    New-AzureStorageShare -Context $storageAccount.Context -Name $fileShareName
  3. Open the Cloud Shell editor:

    code .
  4. Paste in the src/Install-AfsAgent.ps1 script for installing the Azure File Sync Agent on the VM.

  5. Save the script as Install-AfsAgent.ps1.

  6. Use the VM Custom Script Extension to install the agent on the VM:

    # Create a blog storage container that permits anonymous access to invidividual blobs
    $containerName = "deploy-afs"
    New-AzureStorageContainer -Name $containerName -Context $storageAccount.Context -Permission blob
    
    # Upload the Install-Afs.ps1 script to the blob container
    Set-AzureStorageBlobContent -File "Install-AfsAgent.ps1" `
        -Container $containerName `
        -Context $storageAccount.Context 
    
    $fileUri = "$($storageAccount.Context.BlobEndPoint)$containerName/Install-AfsAgent.ps1"
    $Settings = @{
        "fileUris" = @($fileUri)
    }
    $ProtectedSettings = @{
        "commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File Install-AfsAgent.ps1"
    }
    Set-AzVMExtension -ResourceGroupName $resourceGroupName `
        -VMName $vm.Name `
        -Location $vm.Location `
        -Publisher "Microsoft.Compute" `
        -ExtensionType "CustomScriptExtension" `
        -TypeHandlerVersion "1.9" `
        -Settings $Settings `
        -ProtectedSettings $ProtectedSettings `
        -Name provision
  7. Create a sync group by running the src/Deploy-Afs.ps1 script in the same fashion.

Tearing Down

When finished, first delete the server endpoint, cloud endpoint, sync group, and registered server in Storage Sync Service (These resources cannot be deleted by deleting the resource group) and finally remove the remaining Azure resources with:

.\Remove-Lab.ps1

automate-azure-file-sync's People

Contributors

lrakai avatar

Watchers

 avatar  avatar  avatar

Forkers

sa-jackmax

automate-azure-file-sync's Issues

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.