AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
CRM
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 18.05.2015, 11:00   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
This post will round up a small series of how to use Windows PowerShell to provision Dynamics NAV in an automated way. In our examples we do this in the cloud, since here we can already automate the machine and OS deployments, but the techniques here will work in any environment. The key element here is "Automation".


Coffee Break 12 - Provisioning - Automatic installation and deployment of Microsoft Dynamics NAV
Previously we looked at how to use PowerShell to:
  1. Create a Virtual HardDisk (VHD),
  2. Create a Virtual Machine (VM) in the cloud, then
  3. Upload our new VHD to our new VM.
Now, finally we will show how to go ahead an install Dynamics NAV on this new machine.


Why provision?
There is actually a much easier way to get Dynamics NAV running in the cloud: Use the pre-built Dynamics NAV image in Microsoft Azure. If your Azure subscription is an MSDN subscription, then the Azure marketplace should show a Dynamics category when you create a new VM. This category contains a Dynamics NAV image with a complete, pre-configured Dynamics NAV installation. This image can of course also be provisioned using PowerShell. Here's a command that looks for pre-built Dynamics NAV images in the Azure marketplace:

Add-AzureAccount
Get-AzureVMImage | where { $_.ImageFamily -ilike “*NAV*” } | Sort-Object -Descending -Property PublishedDate

But as mentioned above, the key word here is "Automation". So if a ready-built system is not flexible enough, then keep reading.


Prerequisites
In this post we will assume that you have already created a new VM and uploaded a Dynamics NAV product DVD to this machine.

Disclaimer

The nature of flexibility is that you will need and want to customize this to your exact situation. So the script below will likely need changes, but hopefully it will demonstrate well enough how to complete your automated deployment. The script below is based on the provisioning script on the Dynamics NAV 2013 R2 / Dynamics NAV 2015 product DVD (the folder WindowsPowerShellScriptsCloud).

Get started with some settings and load the NAVRemoteAdmin module:

Add-AzureAccount

$DVDLocationLocal = "C:NAVDVD"

$DVDLocationRemote = "C:NAVDVD"

Import-Module $DVDLocationRemoteWindowsPowerShellScriptsCloudNAVRemoteAdministrationNAVRemoteAdministration.psm1

Before we continue take a few moments to run this and see the cmdlets that you now have available from the NAVRemoteAdmin module:

Get-Command -Module NAVRemoteAdministration

Some of these commands are really useful for bridging the gap between your laptop and the cloud and this post will show how much this module helps simplifying remote tasks.

Now we move on and set a few more variables, and then create a PSSession object to access the remote machine.

# Specify the location of your Azure VM

$RemoteMachineAddress = "navnew.cloudapp.net"
$RemoteMachine = "navnew"

$PSSession = New-NAVAdminSession -RemoteMachineAddress $RemoteMachineAddress -AzureServiceName $RemoteMachine -VMAdminUserName vmadmin -VMAdminPassword HelloWorld2



Configure an installation config file by running Setup from the product DVD, and then in the installation wizard select to save configuration.xml. Here, we have configured and saved an installation config file in 1BoxConfigFile.Xml, overwriting the existing demo file:

# Copy installation config file from local machine to the Azure VM

Copy-FileToRemoteMachine -SourceFile $DVDLocationLocalWindowsPowerShellScriptsCloudNAVRemoteAdministrationSamples1BoxConfigFile.Xml -DestinationFile $DVDLocationRemote1BoxConfigFile.xml -Session $PSSession



In case we need a certificate for Web Client connection:

# Generate a self-signed certificate
$Certificate = Install-SelfSignedCertificateRemotely -SubjectName $RemoteMachineAddress -StoreScope 'LocalMachine' -StoreName 'My' -RemoteDirectory "c:Cert" -Session $PSSession



# Or import a signed certificate
# [System.Security.SecureString]$CertificatePfxPasswordAsSecureString = ConvertTo-SecureString $CertificatePfxPassword -AsPlainText -Force

#########

$WebServerSSLCertificateThumbprint = Get-CertificateByThumbprintRemotely
$WebServerSSLCertificateThumbprint = Get-CertificateThumbprint -Certificate $Certificate
$Certificate = Import-PfxFileRemotely `
-PfxFile $CertificatePfxFilePath `
-PfxPassword $CertificatePfxPasswordAsSecureString `
-Session $MySession
#################


# Get installed certificate thumbprint

$WebServerSSLCertificateThumbprint = Get-CertificateByThumbprintRemotely -Certificate $Certificate -Session $PSSession



Install the .NET Framework if needed

Ideally, make sure that the VM you provisioned already has the required version of .NET Framework (4.5). Or if needed you can automate it - look in the provisioning script on the Dynamics NAV 2015 product DVD in WindowsPowerShellScriptsCloudNAVRemoteAdministrationSamplesInstall-DotNETRemotely.ps1 how to install it and restart the VM remotely if needed.



Install Dynamics NAV

# Install prerequisites on VM
$DVDLocationRemote = "C:NAVDVD"
Install-NAVPrerequisitesRemotely -RemoteNavDvdLocation $RemoteNavDvdLocation -Session $PSSession | Out-Null

# Install NAV components from dvd copied to VM
Install-NAVComponentRemotely –RemoteDVDPath $DVDLocationRemote –RemoteConfigurationFilePath $DVDLocationRemote1BoxConfigFile.xml –Session $PSSession



Additional (optional) settings and finishing off

# Remove the default IIS web site to free port 80 for the NAV Web Client
Remove-DefaultWebSiteRemotely -Session $PSSession

#Start the web site
Start-NAVWebClientRemotely -Session $PSSession

#Open Azure endpoint for the Web Client. We assume the web client will always occupy port 443.
$RemoteMachine = "navnew"
$RemoteServiceName = "navnew"
Get-AzureVM -Name $RemoteMachine -ServiceName $RemoteServiceName | Add-AzureEndpoint -Name "NAV_Web_Client" -Protocol "tcp" -LocalPort 443 -PublicPort 443 | Update-AzureVM | Out-Null



This was an example of how to install Dynamics NAV on one machine. Watch out for future posts on how to automate deployment on multiple machines. Example scenario: Automating Cumulative Update deployment.





Jasminka Thunes, Escalation Engineer Dynamics NAV EMEA

Lars Lohndorf-Larsen, Escalation Engineer Dynamics NAV EMEA

Bas Graaf, Senior Software Engineer Dynamics NAV





Источник: http://feedproxy.google.com/~r/Micro...eployment.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 17:59.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.