SlideShare une entreprise Scribd logo
1  sur  58
Развертывания и настройка окружений,
автоматизация и шаблонизация,
инструменты и сценарии,
Azure PowerShell
Provisioning в
Microsoft Azure
Eugene Ilagin https://github.com/ilagin/
• Что такое Provisioning?
• Зачем это знать и где применять?
• Ручная настройка окружения или
автоматическая?
• Provisioning как элемент Continuous
Delivery.
Введение
Hands-on пример
API Server Web Server
Database Server Replication Server
Web API Web App
Replicated
Database
Database
Transactional Replication
• Миграция web-
приложения с on-
premises на IaaS
• Набор скриптов,
позволяющий
сделать все в один
клик
• Azure PowerShell – open source модуль для
Windows PowerShell
• Azure Account. Subscription
• Способы подключения к Azure подписке
• Azure AD
• Сертификат
https://github.com/Azure/azure-powershell/releases
Установка Azure PowerShell и
подключение подписки
Создание Storage Account
Шаг 1.
$commonLocation = "North Europe"
$storageAccountName = "ilagin"
$subscriptionName = Get-AzureSubscription | Select SubscriptionName
New-AzureStorageAccount -StorageAccountName $storageAccountName -Label
"TestStorage" -Location $commonLocation
Select-AzureSubscription $subscriptionName.SubscriptionName.ToString()
Set-AzureSubscription -SubscriptionName
$subscriptionName.SubscriptionName.ToString() -CurrentStorageAccount
$storageAccountName
• Объединение виртуальных машин в LAN
• Доступ к ресурсам в пределах LAN
• Организация VPN
• Создание VNet перед созданием VM
Шаг 2. Создание Виртуальной Сети
<NetworkConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration">
<VirtualNetworkConfiguration>
<Dns />
<VirtualNetworkSites>
<VirtualNetworkSite name="MyVirtualNetwork" Location="North Europe">
<AddressSpace>
<AddressPrefix> 10.0.0.1/26</AddressPrefix>
</AddressSpace>
<Subnets>
<Subnet name="Subnet1">
<AddressPrefix> 10.0.0.1/26</AddressPrefix>
</Subnet>
</Subnets>
</VirtualNetworkSite>
</VirtualNetworkSites>
</VirtualNetworkConfiguration>
</NetworkConfiguration>
Set-AzureVNetConfig -ConfigurationPath
"D:NetworkConfig.netcfg"
• Доступные образы: Get-AzureVMImage.
• Vmdepot.com
• Выбор конфигурации. A0-A11. D1- D14.
• VM с MS SQL стоят дороже.
• Операции создания и provisioning’a
занимают относительно длительное время
Шаг 3.
Создание Виртуальных Машин
$commonLocation = "North Europe"
$webServerImageName = "bd507d3a70934695bc2128e3e5a255ba__RightImage-Windows-
2012-x64-iis8-v14.2"
$dbServerImageName = "fb83b3509582419d99629ce476bcb5c8__SQL-Server-2012-SP2-
11.0.5569.0-Ent-ENU-Win2012-cy15su02"
$virtualNetworkName = "MyVirtualNetwork"
$subnetName = "Subnet1"
$vmNames = @("ilgonetest", "ilgtwotest", "ilgthreetest", "ilgfourtest")
$pwd = "Super Secure Password1"
$instanceSize = "Large"
$userName = "eugene"
$vm0 = New-AzureVMConfig -Name $vmNames[0] -InstanceSize $instanceSize -Image
$webServerImageName
$vm0 | Add-AzureProvisioningConfig -Windows -AdminUserName $userName -Password
$pwd | Set-AzureSubnet $subnetName
$vm0 | New-AzureVM -ServiceName $vmNames[0] -VNetName $virtualNetworkName –
Location $commonLocation
$vm1 = New-AzureVMConfig -Name $vmNames[1] -InstanceSize $instanceSize -
Image $webServerImageName
$vm1 | Add-AzureProvisioningConfig -Windows -AdminUserName $userName -
Password $pwd | Set-AzureSubnet $subnetName
$vm1 | New-AzureVM -ServiceName $vmNames[1] -VNetName $virtualNetworkName
–Location $commonLocation
$vm2 = New-AzureVMConfig -Name $vmNames[2] -InstanceSize $instanceSize -
Image $dbServerImageName
$vm2 | Add-AzureProvisioningConfig -Windows -AdminUserName $userName -
Password $pwd | Set-AzureSubnet $subnetName
$vm2 | New-AzureVM -ServiceName $vmNames[2] -VNetName $virtualNetworkName
–Location $commonLocation
$vm3 = New-AzureVMConfig -Name $vmNames[3] -InstanceSize $instanceSize -
Image $dbServerImageName
$vm3 | Add-AzureProvisioningConfig -Windows -AdminUserName $userName -
Password $pwd | Set-AzureSubnet $subnetName
$vm3 | New-AzureVM -ServiceName $vmNames[3] -VNetName $virtualNetworkName
–Location $commonLocation
• Потеря IP адреса после выключения
• Зависимость ресурсов от IP адреса
Шаг 4. Присвоение статических IP
$vmNames = @("ilgonetest", "ilgtwotest", "ilgthreetest",
"ilgfourtest")
$staticIPs = @("10.0.0.4", "10.0.0.5", "10.0.0.6", "10.0.0.7")
for($i=0; $i -le 3; $i++)
{
Get-AzureVM -ServiceName $vmNames[$i] -Name $vmNames[$i] |
Set-AzureStaticVNetIP -IPAddress $staticIPs[$i] | Update-AzureVM
}
Шаг 5.
Добавление Endpoint’ов к
виртуальным машинам
• Что такое endpoint?
• 2 endpoint’а по умолчанию: RDP, PowerShell
• HTTP(80), SQL(1433) и другие - закрыты
$webVmNames = @("ilgonetest", "ilgtwotest")
foreach($vm in $webVmNames)
{
Get-AzureVM -ServiceName $vm -Name $vm | Add-AzureEndpoint -Name
"HttpIn" -Protocol "tcp" -PublicPort 80 -LocalPort 80 | Update-AzureVM
}
Шаг 6.
Отключение Windows Firewall
$vmNames = @("ilgonetest", "ilgtwotest", "ilgthreetest", "ilgfourtest")
$userName = "eugene"
$pwd = "Super Secure Password1"
$securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force
$credential = New-Object
System.Management.Automation.PSCredential($userName, $securePassword)
foreach($vm in $vmNames)
{
$uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm
$sessionOption = New-PSSessionOption -SkipCACheck:$true -
SkipCNCheck:$true -SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential
$credential -SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {Get-
NetFirewallProfile | Set-NetFirewallProfile –Enabled False}
$session | Remove-PSSession
}
• Обзор доступных вариантов
• VHD – Virtual Hard Drive
• Azure Blob Storage
Шаг 7. Загрузка файлов на VM
$vmNames = @("ilgonetest", "ilgtwotest", "ilgthreetest", "ilgfourtest")
$volumePath = "D:FileStorage.vhd"
$folderToCopy = "D:PRJ"
$azureStoragePaths =
("http://ilagin.blob.core.windows.net/vhdstore/FileStorage0.vhd",
"http://ilagin.blob.core.windows.net/vhdstore/FileStorage1.vhd",
"http://ilagin.blob.core.windows.net/vhdstore/FileStorage2.vhd",
"http://ilagin.blob.core.windows.net/vhdstore/FileStorage3.vhd")
$volume = new-vhd -Path $volumePath -SizeBytes 40MB | `
Mount-VHD -PassThru | `
Initialize-Disk -PartitionStyle mbr -Confirm:$false -PassThru | `
New-Partition -UseMaximumSize -AssignDriveLetter -MbrType IFS | `
Format-Volume -NewFileSystemLabel "VHD" -Confirm:$false
Copy-Item $folderToCopy "$($volume.DriveLetter):" -Recurse
Dismount-VHD $volumePath
for($i=0; $i -le 3; $i++)
{
Add-AzureVhd -Destination $azureStoragePaths[$i] -
LocalFilePath $volumePath
Get-AzureVM $vmNames[$i] $vmNames[$i] | Add-AzureDataDisk
-ImportFrom -MediaLocation $azureStoragePaths[$i] -DiskLabel "EXT"
-LUN 0 | Update-AzureVM
}
Шаг 8.
Удаленное конфигурирование IIS
$webVmNames = @("ilgonetest", "ilgtwotest")
$webPaths = @("E:PRJAPI", "E:PRJWeb")
$userName = "eugene"
$pwd = "Super Secure Password1"
$securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force
$credential = New-Object
System.Management.Automation.PSCredential($userName, $securePassword)
$i = 0
foreach($vm in $webVmNames)
{
$uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm
$sessionOption = New-PSSessionOption -SkipCACheck:$true -
SkipCNCheck:$true -SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential $credential -
SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {
param($path, $user, $password)
Set-ExecutionPolicy RemoteSigned
Import-Module WebAdministration
if (!(Test-Path $path))
{
$path = $path.Replace("E:", "F:")
}
Remove-Item IIS:AppPoolsAdminAppPool -Force -Recurse
$appPool = New-WebAppPool -Name "AdminAppPool"
$appPool.processModel.userName = $user
$appPool.processModel.password = $password
$appPool.processModel.identityType = "SpecificUser"
$appPool | Set-Item
}
Remove-Item IIS:Sites"Default Web Site" -Force -Recurse
Remove-Item IIS:SitesAzureProvisioning -Force -Recurse
New-Item IIS:SitesAzureProvisioning -physicalPath $path -
bindings @{protocol="http";bindingInformation=":80:"}
Set-ItemProperty IIS:SitesAzureProvisioning -name
applicationPool -value AdminAppPool
} -Args $webPaths[$i], $userName, $pwd
$session | Remove-PSSession
$i++
}
Шаг 9.
Добавление Windows пользователей
$sqlVmNames = @("ilgthreetest", "ilgfourtest")
$userName = "eugene"
$pwd = "Super Secure Password1"
$securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($userName,
$securePassword)
$newUserName = "Replication"
foreach($vm in $sqlVmNames)
{
$uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm
$sessionOption = New-PSSessionOption -SkipCACheck:$true -
SkipCNCheck:$true -SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential $credential -
SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {
param($vmName, $userToCreate, $userPassword)
$Computer = [ADSI]("WinNT://" + $vmName)
$LocalAdmin = $Computer.Create("User", $userToCreate)
$LocalAdmin.SetPassword($userPassword)
$LocalAdmin.SetInfo()
$LocalAdmin.FullName = "Azure Provisioning Demo"
$LocalAdmin.SetInfo()
$LocalAdmin.UserFlags = 64 + 65536 #
ADS_UF_PASSWD_CANT_CHANGE + ADS_UF_DONT_EXPIRE_PASSWD
$LocalAdmin.SetInfo()
$objOU = [ADSI]("WinNT://" + $vmName +
"/Administrators,group")
$objOU.add("WinNT://" + $vmName +"/" + $userToCreate)
} -Args $vm, $newUserName, $pwd
$session | Remove-PSSession
}
Шаг 10.
Добавление SQL пользователей
$sqlVmNames = @("ilgthreetest", "ilgfourtest")
$userName = "eugene"
$pwd = "Super Secure Password1"
$securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($userName,
$securePassword)
$newUserName = "Replication"
foreach($vm in $sqlVmNames)
{
$uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm
$sessionOption = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -
SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential $credential -
SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {
param($vmName, $userName, $userPassword)
Set-ExecutionPolicy RemoteSigned
Import-Module SQLPS -DisableNameChecking
$SQLInstanceName = "(local)"
$Server = New-Object -TypeName
Microsoft.SqlServer.Management.Smo.Server -ArgumentList $SQLInstanceName
if ($Server.Logins.Contains($userName))
{
$Server.Logins[$userName].Drop()
}
$Login = New-Object -TypeName
Microsoft.SqlServer.Management.Smo.Login -ArgumentList $Server, $userName
$Login.LoginType =
[Microsoft.SqlServer.Management.Smo.LoginType]::SqlLogin
$Login.PasswordExpirationEnabled = $false
$Login.Create($userPassword)
$Login.AddToRole("sysadmin")
$Login.Alter()
$replicationWindowsUser = $vmName + "Replication"
if ($Server.Logins.Contains($replicationWindowsUser))
{
$Server.Logins[$replicationWindowsUser].Drop()
}
$Login = New-Object -TypeName
Microsoft.SqlServer.Management.Smo.Login -ArgumentList $Server,
$replicationWindowsUser
$Login.LoginType =
[Microsoft.SqlServer.Management.Smo.LoginType]::WindowsUser
$Login.PasswordExpirationEnabled = $false
$Login.Create($userPassword)
$Login.AddToRole("sysadmin")
$Login.Alter()
} -Args $vm, $newUserName, $pwd
$session | Remove-PSSession
}
Шаг 11.
Изменение режима проверки
подлинности SQL сервера.
Включение SQL Server Agent.
$sqlVmNames = @("ilgthreetest", "ilgfourtest")
$userName = "eugene"
$pwd = "Super Secure Password1"
$securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force
$credential = New-Object
System.Management.Automation.PSCredential($userName, $securePassword)
$newUserName = "Replication"
foreach($vm in $sqlVmNames)
{
$uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm
$sessionOption = New-PSSessionOption -SkipCACheck:$true -
SkipCNCheck:$true -SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential $credential
-SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {
param($vmName)
Set-ExecutionPolicy RemoteSigned
Import-Module SQLPS -DisableNameChecking
$sqlServer = new-object
('Microsoft.SqlServer.Management.Smo.Server') '(local)'
$sqlServer.Settings.LoginMode =
[Microsoft.SqlServer.Management.SMO.ServerLoginMode]::Mixed
$sqlServer.Alter()
CD SQLSERVER:SQL$vmName
$Wmi = (get-item .).ManagedComputer
$sqlInstance = $Wmi.Services['MSSQLSERVER']
$sqlInstance.Stop()
Start-Sleep -s 10
$sqlInstance.Start()
$agent = $Wmi.Services['SQLSERVERAGENT']
$agent.Start()
} -Args $vm
$session | Remove-PSSession
}
Шаг 12.
Восстановление бэкапа базы
$sqlVmNames = @("ilgthreetest", "ilgfourtest")
$userName = "eugene"
$pwd = "Super Secure Password1"
$securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force
$credential = New-Object
System.Management.Automation.PSCredential($userName, $securePassword)
foreach($vm in $sqlVmNames)
{
$uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm
$sessionOption = New-PSSessionOption -SkipCACheck:$true -
SkipCNCheck:$true -SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential
$credential -SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {
Set-ExecutionPolicy RemoteSigned
Import-Module SQLPS -DisableNameChecking
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object
Microsoft.SqlServer.Management.Smo.Database($srv, "AzureProvisioning")
$db.Create()
$backupFilePath = "E:PRJdb.bak"
if (!(Test-Path $backupFilePath))
{
$backupFilePath = "F:PRJdb.bak"
}
Restore-SqlDatabase -ServerInstance "(local)" -Database
AzureProvisioning -BackupFile $backupFilePath -ReplaceDatabase
}
$session | Remove-PSSession
}
Шаг 13.1
Создание репликации.
Конфигурация publisher’а
$distributorVm = "ilgthreetest"
$userName = "eugene"
$pwd = "Super Secure Password1"
$securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force
$credential = New-Object
System.Management.Automation.PSCredential($userName,
$securePassword)
$uri = Get-AzureWinRMUri -ServiceName $distributorVm -Name
$distributorVm
$sessionOption = New-PSSessionOption -SkipCACheck:$true -
SkipCNCheck:$true -SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential $credential
-SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {
Set-ExecutionPolicy RemoteSigned
Import-Module SQLPS -DisableNameChecking
$publicationFilePath = "E:PRJpublication.sql"
if (!(Test-Path $publicationFilePath))
{
$publicationFilePath = "F:PRJpublication.sql"
}
Invoke-SqlCmd -InputFile $publicationFilePath -
ServerInstance "(local)"
}
$session | Remove-PSSession
Шаг 13.2
Создание репликации.
Копирование базы
$sqlSubscriberVM = "ilgfourtest"
$userName = "eugene"
$pwd = "Super Secure Password1"
$securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($userName,
$securePassword)
$uri = Get-AzureWinRMUri -ServiceName $sqlSubscriberVM -Name $sqlSubscriberVM
$sessionOption = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -
SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential $credential -
SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {
$pathToShare = "E:PRJ"
if (!(Test-Path $pathToShare))
{
$pathToShare = $pathToShare.Replace("E:", "F:")
}
$netSharePath = "PRJ=" + $pathToShare
net user guest /active:yes
net share $netSharePath "/GRANT:Everyone,FULL"
}
$session | Remove-PSSession
$session | Remove-PSSession
$sqlPublisherVM = "ilgthreetest"
$userName = "eugene"
$pwd = "Super Secure Password1"
$securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force
$credential = New-Object
System.Management.Automation.PSCredential($userName, $securePassword)
$uri = Get-AzureWinRMUri -ServiceName $sqlPublisherVM -Name
$sqlPublisherVM
$sessionOption = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true
-SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential $credential -
SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {
Set-ExecutionPolicy RemoteSigned
Import-Module SQLPS -DisableNameChecking
$path = "E:PRJ"
if (!(Test-Path $path))
{
$path = $path.Replace("E:", "F:")
}
$backupPath = $path + "new.bak"
Backup-SqlDatabase -ServerInstance '(local)' -Database
"AzureProvisioning" -BackupFile $backupPath
$pass="Super Secure Password1"|ConvertTo-SecureString -
AsPlainText -Force
$cred = New-Object
System.Management.Automation.PsCredential("ILGFOURTESTeugene",$pass)
New-PSDrive -Name R -Root "10.0.0.7PRJ" -PSProvider
FileSystem -Credential $cred
Copy-Item $backupPath "R:"
}
$session | Remove-PSSession
Шаг 13.3
Создание репликации.
Восстановление базы
publisher’а
$uri = Get-AzureWinRMUri -ServiceName $sqlSubscriberVM -Name
$sqlSubscriberVM
$sessionOption = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true
-SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential $credential -
SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {
Set-ExecutionPolicy RemoteSigned
Import-Module SQLPS -DisableNameChecking
$srv = new-Object
Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database($srv,
"AzureProvisioning")
$db.Create()
$backupPath = "E:PRJnew.bak"
if (!(Test-Path $backupPath))
{
$backupPath = $backupPath.Replace("E:", "F:")
}
Restore-SqlDatabase -ServerInstance "(local)" -Database
AzureProvisioning -BackupFile $backupPath -ReplaceDatabase
}
Шаг 13.3
Создание репликации.
Настройка подписки
$session | Remove-PSSession
$distributorVm = "ilgthreetest"
$userName = "eugene"
$pwd = "Super Secure Password1"
$securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($userName,
$securePassword)
$uri = Get-AzureWinRMUri -ServiceName $distributorVm -Name $distributorVm
$sessionOption = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -
SkipRevocationCheck:$true
$session = New-PSSession -ConnectionUri $uri -Credential $credential -
SessionOption $sessionOption
Invoke-Command -Session $session -ScriptBlock {
Set-ExecutionPolicy RemoteSigned
Import-Module SQLPS -DisableNameChecking
$supscriptionFilePath = "E:PRJsubscription.sql"
if (!(Test-Path $supscriptionFilePath))
{
$supscriptionFilePath = $supscriptionFilePath.Replace("E:", "F:")
}
Invoke-SqlCmd -InputFile $supscriptionFilePath -ServerInstance "(local)"
}
$session | Remove-PSSession
Шаг 14.
Опциональный
Удаление окружения
$vmNames = @("ilgonetest", "ilgtwotest", "ilgthreetest", "ilgfourtest")
$storageAccountName = "ilagin"
foreach($vm in $vmNames)
{
Remove-AzureDeployment -ServiceName $vm -Slot Production -DeleteVHD
-Force
Remove-AzureService -ServiceName $vm -Force
}
Remove-AzureVNetConfig
Start-Sleep -s 30
Remove-AzureStorageAccount -StorageAccountName $storageAccountName
Заключение
Provisioning в один клик.
Fun или необходимость?
Спасибо за внимание!
eugene.ilagin@gmail.com
https://github.com/ilagin/AzureProvisioning

Contenu connexe

Tendances

Tendances (20)

CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShellCCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
 
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
 
Nodejs first class
Nodejs first classNodejs first class
Nodejs first class
 
How to scheduled jobs in a cloudera cluster without oozie
How to scheduled jobs in a cloudera cluster without oozieHow to scheduled jobs in a cloudera cluster without oozie
How to scheduled jobs in a cloudera cluster without oozie
 
WordPress Plugins: ur doin it wrong
WordPress Plugins: ur doin it wrongWordPress Plugins: ur doin it wrong
WordPress Plugins: ur doin it wrong
 
WebGUI Developers Workshop
WebGUI Developers WorkshopWebGUI Developers Workshop
WebGUI Developers Workshop
 
Dandelion 0.10.0
Dandelion 0.10.0Dandelion 0.10.0
Dandelion 0.10.0
 
Deploying to azure web sites
Deploying to azure web sitesDeploying to azure web sites
Deploying to azure web sites
 
Automated Java Deployments With Rpm
Automated Java Deployments With RpmAutomated Java Deployments With Rpm
Automated Java Deployments With Rpm
 
Czym jest webpack i dlaczego chcesz go używać?
Czym jest webpack i dlaczego chcesz go używać?Czym jest webpack i dlaczego chcesz go używać?
Czym jest webpack i dlaczego chcesz go używać?
 
Building Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsBuilding Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSockets
 
스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
 
Puppet and Apache CloudStack
Puppet and Apache CloudStackPuppet and Apache CloudStack
Puppet and Apache CloudStack
 
ARGUS - THE OMNISCIENT CI
ARGUS - THE OMNISCIENT CIARGUS - THE OMNISCIENT CI
ARGUS - THE OMNISCIENT CI
 
CRESTCon Asia 2018 - Config Password Encryption Gone Wrong
CRESTCon Asia 2018 - Config Password Encryption Gone WrongCRESTCon Asia 2018 - Config Password Encryption Gone Wrong
CRESTCon Asia 2018 - Config Password Encryption Gone Wrong
 
Ant
AntAnt
Ant
 
Moving a Windows environment to the cloud - DevOps Galway Meetup
Moving a Windows environment to the cloud - DevOps Galway MeetupMoving a Windows environment to the cloud - DevOps Galway Meetup
Moving a Windows environment to the cloud - DevOps Galway Meetup
 
Scala Frustrations
Scala FrustrationsScala Frustrations
Scala Frustrations
 
Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 

En vedette

Parallels Automation Executive Summary Apr2010
Parallels Automation Executive Summary Apr2010Parallels Automation Executive Summary Apr2010
Parallels Automation Executive Summary Apr2010
acallaly
 
Scaling Sales & Billing Operations in the Subscription Economy (Accelerate East)
Scaling Sales & Billing Operations in the Subscription Economy (Accelerate East)Scaling Sales & Billing Operations in the Subscription Economy (Accelerate East)
Scaling Sales & Billing Operations in the Subscription Economy (Accelerate East)
Zuora, Inc.
 

En vedette (16)

Bridging the Gap in Corporate Succession Planning
Bridging the Gap in Corporate Succession PlanningBridging the Gap in Corporate Succession Planning
Bridging the Gap in Corporate Succession Planning
 
Azure provisioning at your control
Azure provisioning at your controlAzure provisioning at your control
Azure provisioning at your control
 
Reinventing Your Business By Reinventing Your Talent
Reinventing Your Business By Reinventing Your TalentReinventing Your Business By Reinventing Your Talent
Reinventing Your Business By Reinventing Your Talent
 
Parallels Automation Executive Summary Apr2010
Parallels Automation Executive Summary Apr2010Parallels Automation Executive Summary Apr2010
Parallels Automation Executive Summary Apr2010
 
Ensim Unify Bpos Exchange2010 Provisioning
Ensim Unify Bpos Exchange2010 ProvisioningEnsim Unify Bpos Exchange2010 Provisioning
Ensim Unify Bpos Exchange2010 Provisioning
 
Strategies to automate deployment and provisioning of Microsoft Azure.
Strategies to automate deployment and provisioning of Microsoft Azure.Strategies to automate deployment and provisioning of Microsoft Azure.
Strategies to automate deployment and provisioning of Microsoft Azure.
 
OneBill Software for Telecom Industry
OneBill Software for Telecom IndustryOneBill Software for Telecom Industry
OneBill Software for Telecom Industry
 
Collaborative Leadership in the Borderless Workplace
Collaborative Leadership in the Borderless WorkplaceCollaborative Leadership in the Borderless Workplace
Collaborative Leadership in the Borderless Workplace
 
The leadership lessons of stevejobs by HBR
The leadership lessons of stevejobs by HBRThe leadership lessons of stevejobs by HBR
The leadership lessons of stevejobs by HBR
 
SURE! Subscription Billing & Relationship Management for IaaS providers
SURE! Subscription Billing & Relationship Management for IaaS providers SURE! Subscription Billing & Relationship Management for IaaS providers
SURE! Subscription Billing & Relationship Management for IaaS providers
 
Scaling Sales & Billing Operations in the Subscription Economy (Accelerate East)
Scaling Sales & Billing Operations in the Subscription Economy (Accelerate East)Scaling Sales & Billing Operations in the Subscription Economy (Accelerate East)
Scaling Sales & Billing Operations in the Subscription Economy (Accelerate East)
 
Putting Succession Planning into Practice – Talent Assessment and Development
Putting Succession Planning into Practice – Talent Assessment and DevelopmentPutting Succession Planning into Practice – Talent Assessment and Development
Putting Succession Planning into Practice – Talent Assessment and Development
 
Migration from ISV toward SaaS
Migration from ISV toward SaaSMigration from ISV toward SaaS
Migration from ISV toward SaaS
 
8 Archetypes of Leadership
8 Archetypes of Leadership 8 Archetypes of Leadership
8 Archetypes of Leadership
 
(ARC304) Designing for SaaS: Next-Generation Software Delivery Models on AWS ...
(ARC304) Designing for SaaS: Next-Generation Software Delivery Models on AWS ...(ARC304) Designing for SaaS: Next-Generation Software Delivery Models on AWS ...
(ARC304) Designing for SaaS: Next-Generation Software Delivery Models on AWS ...
 
The Operations Perspective: Scaling Operations in the Subscription Economy
The Operations Perspective: Scaling Operations in the Subscription EconomyThe Operations Perspective: Scaling Operations in the Subscription Economy
The Operations Perspective: Scaling Operations in the Subscription Economy
 

Similaire à Provisioning in Microsoft Azure

Playing with php_on_azure
Playing with php_on_azurePlaying with php_on_azure
Playing with php_on_azure
CEDRIC DERUE
 
What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012
D
 

Similaire à Provisioning in Microsoft Azure (20)

Deploying SharePoint @ Cloud
Deploying SharePoint @ CloudDeploying SharePoint @ Cloud
Deploying SharePoint @ Cloud
 
Charla - SharePoint en la Nube (17Jul2013)
Charla - SharePoint en la Nube (17Jul2013)Charla - SharePoint en la Nube (17Jul2013)
Charla - SharePoint en la Nube (17Jul2013)
 
Azure powershell management
Azure powershell managementAzure powershell management
Azure powershell management
 
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
Automating OSD and Post-OSD Configuration with Powershell and OrchestratorAutomating OSD and Post-OSD Configuration with Powershell and Orchestrator
Automating OSD and Post-OSD Configuration with Powershell and Orchestrator
 
Automating Windows Azure
Automating Windows AzureAutomating Windows Azure
Automating Windows Azure
 
Automating Your Azure Environment
Automating Your Azure EnvironmentAutomating Your Azure Environment
Automating Your Azure Environment
 
Enrique lima azure-it-pro-ps
Enrique lima azure-it-pro-psEnrique lima azure-it-pro-ps
Enrique lima azure-it-pro-ps
 
PowerShell User Group Hamburg - PowerCLI
PowerShell User Group Hamburg - PowerCLIPowerShell User Group Hamburg - PowerCLI
PowerShell User Group Hamburg - PowerCLI
 
Automating Azure VMs with PowerShell
Automating Azure VMs with PowerShellAutomating Azure VMs with PowerShell
Automating Azure VMs with PowerShell
 
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
 
Playing with php_on_azure
Playing with php_on_azurePlaying with php_on_azure
Playing with php_on_azure
 
Azure Powershell Tips
Azure Powershell TipsAzure Powershell Tips
Azure Powershell Tips
 
What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012
 
Dive into DevOps | March, Building with Terraform, Volodymyr Tsap
Dive into DevOps | March, Building with Terraform, Volodymyr TsapDive into DevOps | March, Building with Terraform, Volodymyr Tsap
Dive into DevOps | March, Building with Terraform, Volodymyr Tsap
 
Write php deploy everywhere
Write php deploy everywhereWrite php deploy everywhere
Write php deploy everywhere
 
PowerShell: Through the SharePoint Looking Glass
PowerShell: Through the SharePoint Looking GlassPowerShell: Through the SharePoint Looking Glass
PowerShell: Through the SharePoint Looking Glass
 
Google App Engine Developer - Day4
Google App Engine Developer - Day4Google App Engine Developer - Day4
Google App Engine Developer - Day4
 
SharePoint Administration with PowerShell
SharePoint Administration with PowerShellSharePoint Administration with PowerShell
SharePoint Administration with PowerShell
 
Software Defined Datacenter
Software Defined DatacenterSoftware Defined Datacenter
Software Defined Datacenter
 
AtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and ServerAtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and Server
 

Dernier

CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Dernier (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

Provisioning in Microsoft Azure

  • 1. Развертывания и настройка окружений, автоматизация и шаблонизация, инструменты и сценарии, Azure PowerShell Provisioning в Microsoft Azure Eugene Ilagin https://github.com/ilagin/
  • 2. • Что такое Provisioning? • Зачем это знать и где применять? • Ручная настройка окружения или автоматическая? • Provisioning как элемент Continuous Delivery. Введение
  • 3. Hands-on пример API Server Web Server Database Server Replication Server Web API Web App Replicated Database Database Transactional Replication • Миграция web- приложения с on- premises на IaaS • Набор скриптов, позволяющий сделать все в один клик
  • 4. • Azure PowerShell – open source модуль для Windows PowerShell • Azure Account. Subscription • Способы подключения к Azure подписке • Azure AD • Сертификат https://github.com/Azure/azure-powershell/releases Установка Azure PowerShell и подключение подписки
  • 6. $commonLocation = "North Europe" $storageAccountName = "ilagin" $subscriptionName = Get-AzureSubscription | Select SubscriptionName New-AzureStorageAccount -StorageAccountName $storageAccountName -Label "TestStorage" -Location $commonLocation Select-AzureSubscription $subscriptionName.SubscriptionName.ToString() Set-AzureSubscription -SubscriptionName $subscriptionName.SubscriptionName.ToString() -CurrentStorageAccount $storageAccountName
  • 7. • Объединение виртуальных машин в LAN • Доступ к ресурсам в пределах LAN • Организация VPN • Создание VNet перед созданием VM Шаг 2. Создание Виртуальной Сети
  • 8.
  • 9. <NetworkConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration"> <VirtualNetworkConfiguration> <Dns /> <VirtualNetworkSites> <VirtualNetworkSite name="MyVirtualNetwork" Location="North Europe"> <AddressSpace> <AddressPrefix> 10.0.0.1/26</AddressPrefix> </AddressSpace> <Subnets> <Subnet name="Subnet1"> <AddressPrefix> 10.0.0.1/26</AddressPrefix> </Subnet> </Subnets> </VirtualNetworkSite> </VirtualNetworkSites> </VirtualNetworkConfiguration> </NetworkConfiguration>
  • 11. • Доступные образы: Get-AzureVMImage. • Vmdepot.com • Выбор конфигурации. A0-A11. D1- D14. • VM с MS SQL стоят дороже. • Операции создания и provisioning’a занимают относительно длительное время Шаг 3. Создание Виртуальных Машин
  • 12. $commonLocation = "North Europe" $webServerImageName = "bd507d3a70934695bc2128e3e5a255ba__RightImage-Windows- 2012-x64-iis8-v14.2" $dbServerImageName = "fb83b3509582419d99629ce476bcb5c8__SQL-Server-2012-SP2- 11.0.5569.0-Ent-ENU-Win2012-cy15su02" $virtualNetworkName = "MyVirtualNetwork" $subnetName = "Subnet1" $vmNames = @("ilgonetest", "ilgtwotest", "ilgthreetest", "ilgfourtest") $pwd = "Super Secure Password1" $instanceSize = "Large" $userName = "eugene" $vm0 = New-AzureVMConfig -Name $vmNames[0] -InstanceSize $instanceSize -Image $webServerImageName $vm0 | Add-AzureProvisioningConfig -Windows -AdminUserName $userName -Password $pwd | Set-AzureSubnet $subnetName $vm0 | New-AzureVM -ServiceName $vmNames[0] -VNetName $virtualNetworkName – Location $commonLocation
  • 13. $vm1 = New-AzureVMConfig -Name $vmNames[1] -InstanceSize $instanceSize - Image $webServerImageName $vm1 | Add-AzureProvisioningConfig -Windows -AdminUserName $userName - Password $pwd | Set-AzureSubnet $subnetName $vm1 | New-AzureVM -ServiceName $vmNames[1] -VNetName $virtualNetworkName –Location $commonLocation $vm2 = New-AzureVMConfig -Name $vmNames[2] -InstanceSize $instanceSize - Image $dbServerImageName $vm2 | Add-AzureProvisioningConfig -Windows -AdminUserName $userName - Password $pwd | Set-AzureSubnet $subnetName $vm2 | New-AzureVM -ServiceName $vmNames[2] -VNetName $virtualNetworkName –Location $commonLocation $vm3 = New-AzureVMConfig -Name $vmNames[3] -InstanceSize $instanceSize - Image $dbServerImageName $vm3 | Add-AzureProvisioningConfig -Windows -AdminUserName $userName - Password $pwd | Set-AzureSubnet $subnetName $vm3 | New-AzureVM -ServiceName $vmNames[3] -VNetName $virtualNetworkName –Location $commonLocation
  • 14. • Потеря IP адреса после выключения • Зависимость ресурсов от IP адреса Шаг 4. Присвоение статических IP
  • 15. $vmNames = @("ilgonetest", "ilgtwotest", "ilgthreetest", "ilgfourtest") $staticIPs = @("10.0.0.4", "10.0.0.5", "10.0.0.6", "10.0.0.7") for($i=0; $i -le 3; $i++) { Get-AzureVM -ServiceName $vmNames[$i] -Name $vmNames[$i] | Set-AzureStaticVNetIP -IPAddress $staticIPs[$i] | Update-AzureVM }
  • 16. Шаг 5. Добавление Endpoint’ов к виртуальным машинам • Что такое endpoint? • 2 endpoint’а по умолчанию: RDP, PowerShell • HTTP(80), SQL(1433) и другие - закрыты
  • 17. $webVmNames = @("ilgonetest", "ilgtwotest") foreach($vm in $webVmNames) { Get-AzureVM -ServiceName $vm -Name $vm | Add-AzureEndpoint -Name "HttpIn" -Protocol "tcp" -PublicPort 80 -LocalPort 80 | Update-AzureVM }
  • 19. $vmNames = @("ilgonetest", "ilgtwotest", "ilgthreetest", "ilgfourtest") $userName = "eugene" $pwd = "Super Secure Password1" $securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($userName, $securePassword) foreach($vm in $vmNames) { $uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm $sessionOption = New-PSSessionOption -SkipCACheck:$true - SkipCNCheck:$true -SkipRevocationCheck:$true $session = New-PSSession -ConnectionUri $uri -Credential $credential -SessionOption $sessionOption Invoke-Command -Session $session -ScriptBlock {Get- NetFirewallProfile | Set-NetFirewallProfile –Enabled False} $session | Remove-PSSession }
  • 20. • Обзор доступных вариантов • VHD – Virtual Hard Drive • Azure Blob Storage Шаг 7. Загрузка файлов на VM
  • 21. $vmNames = @("ilgonetest", "ilgtwotest", "ilgthreetest", "ilgfourtest") $volumePath = "D:FileStorage.vhd" $folderToCopy = "D:PRJ" $azureStoragePaths = ("http://ilagin.blob.core.windows.net/vhdstore/FileStorage0.vhd", "http://ilagin.blob.core.windows.net/vhdstore/FileStorage1.vhd", "http://ilagin.blob.core.windows.net/vhdstore/FileStorage2.vhd", "http://ilagin.blob.core.windows.net/vhdstore/FileStorage3.vhd") $volume = new-vhd -Path $volumePath -SizeBytes 40MB | ` Mount-VHD -PassThru | ` Initialize-Disk -PartitionStyle mbr -Confirm:$false -PassThru | ` New-Partition -UseMaximumSize -AssignDriveLetter -MbrType IFS | ` Format-Volume -NewFileSystemLabel "VHD" -Confirm:$false Copy-Item $folderToCopy "$($volume.DriveLetter):" -Recurse Dismount-VHD $volumePath
  • 22. for($i=0; $i -le 3; $i++) { Add-AzureVhd -Destination $azureStoragePaths[$i] - LocalFilePath $volumePath Get-AzureVM $vmNames[$i] $vmNames[$i] | Add-AzureDataDisk -ImportFrom -MediaLocation $azureStoragePaths[$i] -DiskLabel "EXT" -LUN 0 | Update-AzureVM }
  • 24. $webVmNames = @("ilgonetest", "ilgtwotest") $webPaths = @("E:PRJAPI", "E:PRJWeb") $userName = "eugene" $pwd = "Super Secure Password1" $securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($userName, $securePassword) $i = 0 foreach($vm in $webVmNames) { $uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm $sessionOption = New-PSSessionOption -SkipCACheck:$true - SkipCNCheck:$true -SkipRevocationCheck:$true
  • 25. $session = New-PSSession -ConnectionUri $uri -Credential $credential - SessionOption $sessionOption Invoke-Command -Session $session -ScriptBlock { param($path, $user, $password) Set-ExecutionPolicy RemoteSigned Import-Module WebAdministration if (!(Test-Path $path)) { $path = $path.Replace("E:", "F:") } Remove-Item IIS:AppPoolsAdminAppPool -Force -Recurse $appPool = New-WebAppPool -Name "AdminAppPool" $appPool.processModel.userName = $user $appPool.processModel.password = $password $appPool.processModel.identityType = "SpecificUser" $appPool | Set-Item }
  • 26. Remove-Item IIS:Sites"Default Web Site" -Force -Recurse Remove-Item IIS:SitesAzureProvisioning -Force -Recurse New-Item IIS:SitesAzureProvisioning -physicalPath $path - bindings @{protocol="http";bindingInformation=":80:"} Set-ItemProperty IIS:SitesAzureProvisioning -name applicationPool -value AdminAppPool } -Args $webPaths[$i], $userName, $pwd $session | Remove-PSSession $i++ }
  • 27. Шаг 9. Добавление Windows пользователей
  • 28. $sqlVmNames = @("ilgthreetest", "ilgfourtest") $userName = "eugene" $pwd = "Super Secure Password1" $securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($userName, $securePassword) $newUserName = "Replication" foreach($vm in $sqlVmNames) { $uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm $sessionOption = New-PSSessionOption -SkipCACheck:$true - SkipCNCheck:$true -SkipRevocationCheck:$true $session = New-PSSession -ConnectionUri $uri -Credential $credential - SessionOption $sessionOption Invoke-Command -Session $session -ScriptBlock {
  • 29. param($vmName, $userToCreate, $userPassword) $Computer = [ADSI]("WinNT://" + $vmName) $LocalAdmin = $Computer.Create("User", $userToCreate) $LocalAdmin.SetPassword($userPassword) $LocalAdmin.SetInfo() $LocalAdmin.FullName = "Azure Provisioning Demo" $LocalAdmin.SetInfo() $LocalAdmin.UserFlags = 64 + 65536 # ADS_UF_PASSWD_CANT_CHANGE + ADS_UF_DONT_EXPIRE_PASSWD $LocalAdmin.SetInfo() $objOU = [ADSI]("WinNT://" + $vmName + "/Administrators,group") $objOU.add("WinNT://" + $vmName +"/" + $userToCreate) } -Args $vm, $newUserName, $pwd $session | Remove-PSSession }
  • 30. Шаг 10. Добавление SQL пользователей
  • 31. $sqlVmNames = @("ilgthreetest", "ilgfourtest") $userName = "eugene" $pwd = "Super Secure Password1" $securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($userName, $securePassword) $newUserName = "Replication" foreach($vm in $sqlVmNames) { $uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm $sessionOption = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true - SkipRevocationCheck:$true $session = New-PSSession -ConnectionUri $uri -Credential $credential - SessionOption $sessionOption
  • 32. Invoke-Command -Session $session -ScriptBlock { param($vmName, $userName, $userPassword) Set-ExecutionPolicy RemoteSigned Import-Module SQLPS -DisableNameChecking $SQLInstanceName = "(local)" $Server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $SQLInstanceName if ($Server.Logins.Contains($userName)) { $Server.Logins[$userName].Drop() } $Login = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Login -ArgumentList $Server, $userName $Login.LoginType = [Microsoft.SqlServer.Management.Smo.LoginType]::SqlLogin $Login.PasswordExpirationEnabled = $false $Login.Create($userPassword) $Login.AddToRole("sysadmin") $Login.Alter()
  • 33. $replicationWindowsUser = $vmName + "Replication" if ($Server.Logins.Contains($replicationWindowsUser)) { $Server.Logins[$replicationWindowsUser].Drop() } $Login = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Login -ArgumentList $Server, $replicationWindowsUser $Login.LoginType = [Microsoft.SqlServer.Management.Smo.LoginType]::WindowsUser $Login.PasswordExpirationEnabled = $false $Login.Create($userPassword) $Login.AddToRole("sysadmin") $Login.Alter() } -Args $vm, $newUserName, $pwd $session | Remove-PSSession }
  • 34. Шаг 11. Изменение режима проверки подлинности SQL сервера. Включение SQL Server Agent.
  • 35. $sqlVmNames = @("ilgthreetest", "ilgfourtest") $userName = "eugene" $pwd = "Super Secure Password1" $securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($userName, $securePassword) $newUserName = "Replication" foreach($vm in $sqlVmNames) { $uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm $sessionOption = New-PSSessionOption -SkipCACheck:$true - SkipCNCheck:$true -SkipRevocationCheck:$true $session = New-PSSession -ConnectionUri $uri -Credential $credential -SessionOption $sessionOption Invoke-Command -Session $session -ScriptBlock { param($vmName)
  • 36. Set-ExecutionPolicy RemoteSigned Import-Module SQLPS -DisableNameChecking $sqlServer = new-object ('Microsoft.SqlServer.Management.Smo.Server') '(local)' $sqlServer.Settings.LoginMode = [Microsoft.SqlServer.Management.SMO.ServerLoginMode]::Mixed $sqlServer.Alter() CD SQLSERVER:SQL$vmName $Wmi = (get-item .).ManagedComputer $sqlInstance = $Wmi.Services['MSSQLSERVER'] $sqlInstance.Stop() Start-Sleep -s 10 $sqlInstance.Start() $agent = $Wmi.Services['SQLSERVERAGENT'] $agent.Start() } -Args $vm $session | Remove-PSSession }
  • 38. $sqlVmNames = @("ilgthreetest", "ilgfourtest") $userName = "eugene" $pwd = "Super Secure Password1" $securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($userName, $securePassword) foreach($vm in $sqlVmNames) { $uri = Get-AzureWinRMUri -ServiceName $vm -Name $vm $sessionOption = New-PSSessionOption -SkipCACheck:$true - SkipCNCheck:$true -SkipRevocationCheck:$true $session = New-PSSession -ConnectionUri $uri -Credential $credential -SessionOption $sessionOption Invoke-Command -Session $session -ScriptBlock { Set-ExecutionPolicy RemoteSigned Import-Module SQLPS -DisableNameChecking
  • 39. $srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)") $db = New-Object Microsoft.SqlServer.Management.Smo.Database($srv, "AzureProvisioning") $db.Create() $backupFilePath = "E:PRJdb.bak" if (!(Test-Path $backupFilePath)) { $backupFilePath = "F:PRJdb.bak" } Restore-SqlDatabase -ServerInstance "(local)" -Database AzureProvisioning -BackupFile $backupFilePath -ReplaceDatabase } $session | Remove-PSSession }
  • 41. $distributorVm = "ilgthreetest" $userName = "eugene" $pwd = "Super Secure Password1" $securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($userName, $securePassword) $uri = Get-AzureWinRMUri -ServiceName $distributorVm -Name $distributorVm $sessionOption = New-PSSessionOption -SkipCACheck:$true - SkipCNCheck:$true -SkipRevocationCheck:$true $session = New-PSSession -ConnectionUri $uri -Credential $credential -SessionOption $sessionOption Invoke-Command -Session $session -ScriptBlock { Set-ExecutionPolicy RemoteSigned Import-Module SQLPS -DisableNameChecking
  • 42. $publicationFilePath = "E:PRJpublication.sql" if (!(Test-Path $publicationFilePath)) { $publicationFilePath = "F:PRJpublication.sql" } Invoke-SqlCmd -InputFile $publicationFilePath - ServerInstance "(local)" } $session | Remove-PSSession
  • 44. $sqlSubscriberVM = "ilgfourtest" $userName = "eugene" $pwd = "Super Secure Password1" $securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($userName, $securePassword) $uri = Get-AzureWinRMUri -ServiceName $sqlSubscriberVM -Name $sqlSubscriberVM $sessionOption = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true - SkipRevocationCheck:$true $session = New-PSSession -ConnectionUri $uri -Credential $credential - SessionOption $sessionOption
  • 45. Invoke-Command -Session $session -ScriptBlock { $pathToShare = "E:PRJ" if (!(Test-Path $pathToShare)) { $pathToShare = $pathToShare.Replace("E:", "F:") } $netSharePath = "PRJ=" + $pathToShare net user guest /active:yes net share $netSharePath "/GRANT:Everyone,FULL" } $session | Remove-PSSession
  • 46. $session | Remove-PSSession $sqlPublisherVM = "ilgthreetest" $userName = "eugene" $pwd = "Super Secure Password1" $securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($userName, $securePassword) $uri = Get-AzureWinRMUri -ServiceName $sqlPublisherVM -Name $sqlPublisherVM $sessionOption = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true $session = New-PSSession -ConnectionUri $uri -Credential $credential - SessionOption $sessionOption
  • 47. Invoke-Command -Session $session -ScriptBlock { Set-ExecutionPolicy RemoteSigned Import-Module SQLPS -DisableNameChecking $path = "E:PRJ" if (!(Test-Path $path)) { $path = $path.Replace("E:", "F:") } $backupPath = $path + "new.bak" Backup-SqlDatabase -ServerInstance '(local)' -Database "AzureProvisioning" -BackupFile $backupPath
  • 48. $pass="Super Secure Password1"|ConvertTo-SecureString - AsPlainText -Force $cred = New-Object System.Management.Automation.PsCredential("ILGFOURTESTeugene",$pass) New-PSDrive -Name R -Root "10.0.0.7PRJ" -PSProvider FileSystem -Credential $cred Copy-Item $backupPath "R:" } $session | Remove-PSSession
  • 50. $uri = Get-AzureWinRMUri -ServiceName $sqlSubscriberVM -Name $sqlSubscriberVM $sessionOption = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true $session = New-PSSession -ConnectionUri $uri -Credential $credential - SessionOption $sessionOption Invoke-Command -Session $session -ScriptBlock { Set-ExecutionPolicy RemoteSigned Import-Module SQLPS -DisableNameChecking $srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)") $db = New-Object Microsoft.SqlServer.Management.Smo.Database($srv, "AzureProvisioning") $db.Create() $backupPath = "E:PRJnew.bak"
  • 51. if (!(Test-Path $backupPath)) { $backupPath = $backupPath.Replace("E:", "F:") } Restore-SqlDatabase -ServerInstance "(local)" -Database AzureProvisioning -BackupFile $backupPath -ReplaceDatabase }
  • 53. $session | Remove-PSSession $distributorVm = "ilgthreetest" $userName = "eugene" $pwd = "Super Secure Password1" $securePassword = ConvertTo-SecureString $pwd -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($userName, $securePassword) $uri = Get-AzureWinRMUri -ServiceName $distributorVm -Name $distributorVm $sessionOption = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true - SkipRevocationCheck:$true $session = New-PSSession -ConnectionUri $uri -Credential $credential - SessionOption $sessionOption Invoke-Command -Session $session -ScriptBlock {
  • 54. Set-ExecutionPolicy RemoteSigned Import-Module SQLPS -DisableNameChecking $supscriptionFilePath = "E:PRJsubscription.sql" if (!(Test-Path $supscriptionFilePath)) { $supscriptionFilePath = $supscriptionFilePath.Replace("E:", "F:") } Invoke-SqlCmd -InputFile $supscriptionFilePath -ServerInstance "(local)" } $session | Remove-PSSession
  • 56. $vmNames = @("ilgonetest", "ilgtwotest", "ilgthreetest", "ilgfourtest") $storageAccountName = "ilagin" foreach($vm in $vmNames) { Remove-AzureDeployment -ServiceName $vm -Slot Production -DeleteVHD -Force Remove-AzureService -ServiceName $vm -Force } Remove-AzureVNetConfig Start-Sleep -s 30 Remove-AzureStorageAccount -StorageAccountName $storageAccountName
  • 57. Заключение Provisioning в один клик. Fun или необходимость?