Skip to content

Commit

Permalink
Adds session resources from 2019 Microsoft Ignite - The Tour - Stockholm
Browse files Browse the repository at this point in the history
  • Loading branch information
janegilring committed Apr 20, 2019
1 parent 7c4022d commit e4c16ad
Show file tree
Hide file tree
Showing 17 changed files with 858 additions and 0 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Install-Module -Name Az -Force

Connect-AzAccount
Set-AzContext -SubscriptionId 1f732d91-23e3-40c5-b17e-59a82b645596

Import-Module Az.Automation

$PSDefaultParameterValues = @{
"*AzAutomation*:ResourceGroupName" = 'West-Europe-Management'
"*AzAutomation*:AutomationAccountName" = 'Automation-West-Europe'
}

# HybridFileServers - import configuration to Azure Automation
$SourcePath = '.\AzureFileSyncAgent\HybridFileServer.ps1'
Import-AzAutomationDscConfiguration -SourcePath $SourcePath -Force -Published -Tags @{Source='Git'}

# HybridFileServers - compile configuration in Azure Automation
$ConfigurationData = Import-PowerShellDataFile -Path '.\AzureFileSyncAgent\HybridFileServer_Configuration_Data.psd1'
$CompilationJob = Start-AzAutomationDscCompilationJob -ConfigurationName HybridFileServer -ConfigurationData $ConfigurationData


#region DSC LCM

$LCMComputerName = 'BranchFS1'
$NodeConfigurationName = 'HybridFileServer.BranchFS1'
$DSCMOFDirectory = 'C:\temp\AzureAutomationDscMetaConfiguration'

# Create the metaconfigurations
$Params = @{
RegistrationUrl = 'https://we-agentservice-prod-1.azure-automation.net/accounts/a8072ea5-60ec-4209-b9b0-64c519efbc73';
RegistrationKey = '1234567W+enQyQXHd9cKX9/FI8WOZgumoQC5ks+jXo/TBwOjxeW1k2gQywhiPHNoDUiMf6abcde';
ComputerName = @($LCMComputerName);
NodeConfigurationName = $NodeConfigurationName;
RefreshFrequencyMins = 720;
ConfigurationModeFrequencyMins = 360;
RebootNodeIfNeeded = $False;
AllowModuleOverwrite = $True;
ConfigurationMode = 'ApplyAndAutoCorrect';
ActionAfterReboot = 'ContinueConfiguration';
ReportOnly = $False; # Set to $True to have machines only report to AA DSC but not pull from it
OutputPath = $DSCMOFDirectory
}

. '.\AzureAutomationDscMetaConfiguration.ps1'

AzureAutomationDscMetaConfiguration @Params

$LCMComputerName = $env:COMPUTERNAME
$DSCMOFDirectory = 'C:\temp\AzureAutomationDscMetaConfiguration'

Set-DscLocalConfigurationManager -Path $DSCMOFDirectory -ComputerName $LCMComputerName -Force

Update-DscConfiguration -Wait -Verbose -CimSession $LCMComputerName

Get-DscLocalConfigurationManager -CimSession $LCMComputerName

#endregion
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# The DSC configuration that will generate metaconfigurations
[DscLocalConfigurationManager()]
Configuration AzureAutomationDscMetaConfiguration
{
param
(
[Parameter(Mandatory=$True)]
[String]$RegistrationUrl,

[Parameter(Mandatory=$True)]
[String]$RegistrationKey,

[Parameter(Mandatory=$True)]
[String[]]$ComputerName,

[Int]$RefreshFrequencyMins = 30,

[Int]$ConfigurationModeFrequencyMins = 15,

[String]$ConfigurationMode = "ApplyAndMonitor",

[String]$NodeConfigurationName,

[Boolean]$RebootNodeIfNeeded= $False,

[String]$ActionAfterReboot = "ContinueConfiguration",

[Boolean]$AllowModuleOverwrite = $False,

[Boolean]$ReportOnly
)

if(!$NodeConfigurationName -or $NodeConfigurationName -eq "")
{
$ConfigurationNames = $null
}
else
{
$ConfigurationNames = @($NodeConfigurationName)
}

if($ReportOnly)
{
$RefreshMode = "PUSH"
}
else
{
$RefreshMode = "PULL"
}

Node $ComputerName
{

Settings
{
RefreshFrequencyMins = $RefreshFrequencyMins
RefreshMode = $RefreshMode
ConfigurationMode = $ConfigurationMode
AllowModuleOverwrite = $AllowModuleOverwrite
RebootNodeIfNeeded = $RebootNodeIfNeeded
ActionAfterReboot = $ActionAfterReboot
ConfigurationModeFrequencyMins = $ConfigurationModeFrequencyMins
}

if(!$ReportOnly)
{
ConfigurationRepositoryWeb AzureAutomationDSC
{
ServerUrl = $RegistrationUrl
RegistrationKey = $RegistrationKey
ConfigurationNames = $ConfigurationNames
}

ResourceRepositoryWeb AzureAutomationDSC
{
ServerUrl = $RegistrationUrl
RegistrationKey = $RegistrationKey
}
}

ReportServerWeb AzureAutomationDSC
{
ServerUrl = $RegistrationUrl
RegistrationKey = $RegistrationKey
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
Configuration HybridFileServer
{
$FileSyncPackageLocalPath = "C:\Windows\Temp\StorageSyncAgent.msi"
$AzureFileSyncSubscriptionId = Get-AutomationVariable -Name "AzureFileSyncSubscriptionId"
$AzureFileSyncResourceGroup = Get-AutomationVariable -Name "AzureFileSyncResourceGroup"
$AzureFileSyncInstanceName = Get-AutomationVariable -Name "AzureFileSyncInstanceName"
$AzureCredential = Get-AutomationPSCredential -Name "AzureFileSyncNodeRegistration"

Import-DscResource -ModuleName xPSDesiredStateConfiguration -ModuleVersion 8.4.0.0
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName PackageManagement -ModuleVersion 1.3.1
Import-DscResource -ModuleName AzureFileSyncDsc -ModuleVersion 1.0.0.3
Import-DscResource -ModuleName StorageDsc -ModuleVersion 4.4.0.0

Node $AllNodes.Where{$PSItem.NodeType -eq 'HybridFileServer'}.NodeName {

Service FileSyncService
{
Name = "FileSyncSvc"
State = "Running"
DependsOn = "[Package]FileSync"
}

xRemoteFile FileSyncPackage {
Uri = "https://download.microsoft.com/download/1/8/D/18DC8184-E7E2-45EF-823F-F8A36B9FF240/StorageSyncAgent_V4_WS2019.msi"
DestinationPath = $FileSyncPackageLocalPath
}

Package FileSync {
Ensure = "Present"
Path = $FileSyncPackageLocalPath
Name = "Storage Sync Agent"
ProductId = "F5EA481D-EECC-4AA8-B62D-108001DA2462"
Arguments = '/quiet'
DependsOn = "[xRemoteFile]FileSyncPackage"
}

PackageManagement AzureRMPowerShellModule {

Name = 'AzureRM'
ProviderName = 'PowerShellGet'
RequiredVersion = '6.13.1'
Source = 'PSGallery'
DependsOn = "[Package]FileSync"

}

AzureFileSyncAgent Registration {

AzureSubscriptionId = $AzureFileSyncSubscriptionId
AzureFileSyncResourceGroup = $AzureFileSyncResourceGroup
AzureFileSyncInstanceName = $AzureFileSyncInstanceName
AzureCredential = $AzureCredential
DependsOn = '[Service]FileSyncService'

}

if ($NodeName -like "BranchFS*") {

WaitForDisk Disk1
{
DiskId = 1
RetryIntervalSec = 60
RetryCount = 60
DependsOn = '[AzureFileSyncAgent]Registration'
}

Disk DVolume
{
DiskId = 1
DriveLetter = 'D'
Size = 100GB
DependsOn = '[WaitForDisk]Disk1'
}

File DirectoryDemoData
{
Ensure = "Present" # Ensure the directory is Present on the target node.
Type = "Directory" # The default is File.
DestinationPath = "D:\NICDemoData"
DependsOn = '[Disk]DVolume'
}

AzureFileSyncServerEndpoint DemoData {

AzureSubscriptionId = $AzureFileSyncSubscriptionId
AzureFileSyncResourceGroup = $AzureFileSyncResourceGroup
AzureFileSyncInstanceName = $AzureFileSyncInstanceName
AzureFileSyncGroup = $node.AzureFileSyncGroup
AzureCredential = $AzureCredential
ServerLocalPath = $Node.AzureFileSyncServerEndpointLocalPath
CloudTiering = $node.AzureFileSyncCloudTiering
TierFilesOlderThanDays = $node.AzureFileSyncTierFilesOlderThanDays
DependsOn = '[File]DirectoryDemoData'

}

}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$ConfigurationData = @{
AllNodes = @(
@{
NodeName = '*'
PSDscAllowPlainTextPassword = $true
PSDscAllowDomainUser = $true
NodeType = 'HybridFileServer'
},
@{
NodeName = 'BranchFS'
AzureFileSyncGroup = 'NICDemoData'
AzureFileSyncServerEndpointLocalPath = 'D:\NICDemoData'
AzureFileSyncCloudTiering = $true
AzureFileSyncTierFilesOlderThanDays = 365
},
@{
NodeName = 'ClusterFS'
}
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Configuration HybridFileServer
{
param (
$AzureCredential = (Get-Credential)
)

Import-DscResource -ModuleName xPSDesiredStateConfiguration -ModuleVersion 8.4.0.0
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName PackageManagement -ModuleVersion 1.3.1
Import-DscResource -ModuleName AzureFileSyncDsc -ModuleVersion 1.0.0.3
Import-DscResource -ModuleName StorageDsc -ModuleVersion 4.4.0.0

Node FS01 {

AzureFileSyncServerEndpoint Data {

AzureSubscriptionId = 'c0fda861-1234-5678-9ede-fa1908101500'
AzureFileSyncResourceGroup = 'File-Sync-Rg'
AzureFileSyncInstanceName = 'FileSync01'
AzureFileSyncGroup = 'FileServers'
AzureCredential = $AzureCredential
ServerLocalPath = 'D:\Data'
CloudTiering = $true
TierFilesOlderThanDays = '365'

}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$ConfigurationData = @{
AllNodes = @(
@{
NodeName = '*'
PSDscAllowPlainTextPassword = $true
PSDscAllowDomainUser = $true
NodeType = 'HybridFileServer'
},
@{
NodeName = 'BranchFS'
AzureFileSyncGroup = 'DemoData'
AzureFileSyncServerEndpointLocalPath = 'D:\DemoData'
AzureFileSyncCloudTiering = $true
AzureFileSyncTierFilesOlderThanDays = 365
},
@{
NodeName = 'ClusterFS'
}
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Configuration HybridFileServer
{
$FileSyncPackageLocalPath = "C:\Windows\Temp\StorageSyncAgent.msi"
$AzureFileSyncSubscriptionId = Get-AutomationVariable -Name "AzureFileSyncSubscriptionId"
$AzureFileSyncResourceGroup = Get-AutomationVariable -Name "AzureFileSyncResourceGroup"
$AzureFileSyncInstanceName = Get-AutomationVariable -Name "AzureFileSyncInstanceName"
$AzureCredential = Get-AutomationPSCredential -Name "AzureFileSyncNodeRegistration"

Import-DscResource -ModuleName xPSDesiredStateConfiguration -ModuleVersion 8.4.0.0
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName PackageManagement -ModuleVersion 1.3.1
Import-DscResource -ModuleName AzureFileSyncDsc -ModuleVersion 1.0.0.3
Import-DscResource -ModuleName StorageDsc -ModuleVersion 4.4.0.0

Node 'HybridFileServer' {

AzureFileSyncServerEndpoint DemoData {

AzureSubscriptionId = $AzureFileSyncSubscriptionId
AzureFileSyncResourceGroup = $AzureFileSyncResourceGroup
AzureFileSyncInstanceName = $AzureFileSyncInstanceName
AzureFileSyncGroup = $node.AzureFileSyncGroup
AzureCredential = $AzureCredential
ServerLocalPath = $Node.AzureFileSyncServerEndpointLocalPath
CloudTiering = $node.AzureFileSyncCloudTiering
TierFilesOlderThanDays = $node.AzureFileSyncTierFilesOlderThanDays
DependsOn = '[File]DirectoryDemoData'

}

}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit e4c16ad

Please sign in to comment.