Translate

Friday, July 20, 2012

Model deployment AX 2012

Hi,

Recently I came across a very nice article "Model deployment among Multiple AOS Instance". Below script enables to deploy Model and perform all steps automatically like Starting service, application compilation, sync etc.

Steps:
  
- Load AX Management scripts 
 - Stop the AOS
 - Clean up (delete layers)
 - Import new ax model
 - Start AOS
 - Do a sync
 - Do a compile
 - Do a CIL generation
 - You can not test your code

Script :
param(
    [string] $MODELPATH = $(throw "Model path required"),
    [string] $AXCONFIGPATH = $(throw "AX configuration file required"),
    [string] $MODELTODEPLOY = "PCGModel",
    [string] $DOAXSYNC = "y", 
    [string] $DOAXCOMPILE = "y", 
    [string] $LAYERSTOCLEAN = "",
    [long] $AXIMPORTTIMEOUT = 300000,
    [long] $AXSYNCTIMEOUT = 1800000,
    [long] $AXCOMPILETIMEOUT = 10800000
    )

& 'C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\Microsoft.Dynamics.ManagementUtilities.ps1'

if(!(Test-Path $MODELPATH))
{
    Throw ("Error: Source path " + $MODELPATH + "does not exist")
}
if(!(Test-Path $AXCONFIGPATH))
{
    Throw ("Error: Could not find configuration file " + $AXCONFIGPATH)
}

$computername = gc env:computername

# Get the client bin directory from the config file
$axClientPath = [string] (type $AXCONFIGPATH | Select-String "bindir")
$axClientPath = ($axClientPath.split(","))[2]

# Get the server name from the config file
$aosServer = [string] (type $AXCONFIGPATH | Select-String "aos2")
$aosServer = ($aosServer.split(","))[2]
$aosInstance = ($aosServer.split("@"))[0]
$aosServer = ($aosServer.split("@"))[1]
if ($aosServer -eq $null)
{
    Throw "Error: The config file is incorrect (does not contain the AOS Instance name)"
}
$aosServer = ($aosServer.split(":"))[0]


# Make sure we're on the right server
if ($aosServer -ne (gc env:computername))
{
    Throw "Error: Script must be run on the AOS server the config file points to"
}

# Get the layer and layercode from the configuration
$buildlayer = [string] (type $AXCONFIGPATH | Select-String "aol,")
$buildlayer = ($buildlayer.split(","))[2]
$buildlayerCode = [string] (type $AXCONFIGPATH | Select-String "aolcode,")
$buildlayerCode = ($buildlayerCode.split(","))[2]

if($buildLayerCode -eq $null) # -and $buildLayerCode -ne "usr") -or $buildLayerCode -eq ""))
{
    Throw ("No layer specified for build layer " + $buildlayer)
}

# Get the log path
$logPath = [string] (type $AXCONFIGPATH | Select-String "logDir")
$logPath = ($logPath.split(","))[2]
$logPath = $env:UserProfile + '\Microsoft\Dynamics Ax\Log\'

# Get the AOS port from the configuration (aos name is ignored when connecting, so port is the only valid identifier)
$aosPort = [string] (type $AXCONFIGPATH | Select-String "aos2")
$aosPort = ($aosPort.split(","))[2]
$aosPort = ($aosPort.split(":"))[1]

# Open the list of servers running on this machine
$aosRegistryPath = "hklm:`\SYSTEM`\CurrentControlSet`\services`\Dynamics Server`\6.0"
$aosServers = Get-Item $aosRegistryPath
$aosServers = $aosServers.GetSubKeyNames()
$aosService = ""
for ($i=0; $i -le ($aosServers.Length - 1); $i++)
{
# Get the server properties, to find the current active config
    $serverProperties = Get-ItemProperty ($aosRegistryPath + "`\" + $aosServers[$i])
# Get the configuration
    $serverConfiguration = Get-ItemProperty ($aosRegistryPath + "`\" + $aosServers[$i] + "`\" + $serverProperties.Current)
# If this is our AOS port, get out of the loop
    if ($serverConfiguration.port -eq $aosPort)
    {
        $aosService = "AOS60`$" + $aosServers[$i]
        break
    }
    $aosService = ""
}

# If we didn't find it, throw an error
if ($aosService -eq "")
{
    Throw "Error: Could not find configuration for server running on port " + $aosPort
}

# Query the service for status
$aosServiceObj = Get-Service $aosService
if ($aosServiceObj.Status -eq "Running")
{
# If it's running, stop the service
    Stop-Service -WarningAction:SilentlyContinue ($aosService)
}
# Refresh our object
$aosServiceObj.Refresh()
if ($aosServiceObj.Status -eq "Running")
{
# If it's still running, something's wrong!
    Throw "Error: AOS service still running"
}


# Function to clear out layer artifacts
Function CleanLayer([string] $layer)
{
    Uninstall-AXModel -Layer $layer -Config $aosInstance -NoPrompt

}

CleanLayer "usr"
CleanLayer $buildLayer


Install-AXModel -File $MODELPATH -NoPrompt -Config $aosInstance


Set-AXModelStore -Config $aosInstance -NoInstallMode



# Start the AOS service
Start-Service -WarningAction:SilentlyContinue ($aosService)

# Refresh our object
$aosServiceObj.Refresh()
if ($aosServiceObj.Status -ne "Running")
{
# If it's not running, something's wrong!
    Throw "Error: AOS service could not be started"
}


$params = "`"" + $AXCONFIGPATH + "`" -lazyclassloading -lazytableloading -model=" + ($MODELTODEPLOY)
    
if ($DOAXSYNC -eq "y")
{
    $date = Get-Date


    $axProcess = Start-Process -PassThru ($axClientPath + "`\Ax32.exe") -ArgumentList ($params + " -StartupCmd=Synchronize")
    if ($axProcess.WaitForExit($AXSYNCTIMEOUT) -eq $false)
    {
        Throw ("Error: Synchronize did not complete within " + $AXSYNCTIMEOUT / 60000 + " minutes")
    }
}

if ($DOAXCOMPILE -eq "y")
{
    $date = Get-Date
    Write-Host "[AX CHECK] Compiling application ... takes a long time; Task started: " $date

    $axProcess = Start-Process -PassThru ($axClientPath + "`\Ax32.exe") -ArgumentList ($params + " -StartupCmd=CompileAll")
    if ($axProcess.WaitForExit($AXCOMPILETIMEOUT) -eq $false)
    {
        Throw ("Error: Compile did not complete within " + $AXCOMPILETIMEOUT / 60000 + " minutes")
    }
}

Shared by - 
http://axfaq.blogspot.in/2012/02/ax2012-utils-its-all-about-scripting_22.html

Sunday, July 15, 2012

DYNAMICS AX 2012 - RETAIL


MICROSOFT DYNAMICS AX 2012 - RETAIL


Microsoft Dynamics AX 2012 for Retail - POS Demo



Microsoft Dynamics AX 2012 for Retail - Special Orders




Microsoft Dynamics AX 2012 for Retail - Social Commerce




Microsoft Dynamic AX 2012 for Retail - Item Replenishment



Monday, July 2, 2012

Benchmark AX 2012

Sunday, July 1, 2012

AX 2012 Developer Resources

AX 2012 Developer Resources



This page collects the AX 2012 Development Articles available at blog, as well as the most relevant links to Microsoft documentation. They are arranged by topic. You will find duplicate links for articles that touch multiple topics.


General Topics
Microsoft Guide: What's New for Developers (download) [fixed link - thanks to reader Waldemar Pross]
Microsoft Guide: New, Changed and Deprecated Features (download)
Microsoft Whitepaper: Deploying Customizations Across Environments (download)
Dynamics AX 2012 System Requirements (download)
Deploying AX 2012 Code
Importing Data Using the Excel Add-Ins


X++ Language
X++ as a Managed Language in the .NET Runtime (code walkthrough)
AX 2012 X++ Language Changes, Stricter Syntax (MSDN Article)
.NET Interop to X++ Issues when X++ runs as CIL (MSDN Blog)
Deploying AX 2012 Code
New Query Object Features (code walkthrough)
Creating Code Snippets and method templates (code walkthrough)


Data Access
Computed View Columns (code walkthrough)
Valid Time State/Date Effective Framework - Part 1: Creating the table (code walkthrough)
Valid Time State/Date Effective Framework - Part 2: Querying time state tables (code walkthrough)
Microsoft Whitepaper: Using Date Effective Patterns (download)


Debugging
Debugging X++ Running in CLR using Visual Studio (code walkthrough)


Events
Introduction
Eventing Basics (code walkthrough)
Managed Handlers for Pre/Post events (code walkthrough)
Managed Code Handlers for Delegates (limitations) (code walkthrough)
Microsoft Whitepaper: Eventing (download)
Eventing Terminology and Keywords (MSDN Article)
Naming Conventions for Delegates and Event Handlers (MSDN Article)


Reporting
Multiple instances of Reporting Services on the same machine (TechNet Article)
Microsoft Whitepaper: Report Programming Model for Dynamics AX 2012 (download)


SysOperation Framework
From RunBase to SysOperation: Business Operation Framework (code walkthrough)
From RunBase to SysOperation: Business Operation Framework (SysOperation query and customizing BOF dialog) (code walkthrough)
MSDN SysOperation Framework (MSDN Article)
SysOperation Framework Whitepaper (download)


Foreign-Key Table Relationships
RecIds as Foreign Keys (code walkthrough)
Microsoft Whitepaper: Migrating EDT Relations (download)


UnitOfWork
Unit of Work Magic (code walkthrough)


Table Inheritance
Microsoft Whitepaper: Developing with Table Inheritance (download)


Model Architecture
Models and Layers Basics (code walkthrough)
Powerful Combination of Models and Events for No-Merge Code Solutions (code walkthrough)
Deploying AX 2012 Code


Managed Code
Using Visual Studio 2010 with AX 2012 (code walkthrough)
Writing and Calling Managed Code from AX (code walkthrough)
Limitations for Managed Code Event Handlers (code walkthrough)
Proxy Classes Gotcha (code walkthrough)
Creating Proxies for Kernel Classes (classes not visible in the AOT) (code walkthrough)
Microsoft Whitepaper: Selecting the Best Development Technology for Your Scenario (download)
X++ as a Managed Language in the .NET Runtime (code walkthrough)
.NET Assembly Deployment in AX 2012
.NET Interop to X++ Issues when X++ runs as CIL (MSDN Blog)


Services
From RunBase to SysOperation: Business Operation Framework (code walkthrough)
Using System Query Service in WPF (code walkthrough)
MSDN Business Operation Framework (MSDN Article)
Microsoft Whitepaper: Services (download)
Consuming External Webservices (code walkthrough)
Trusted Intermediary in AIF (code walkthrough)


Security
Trusted Intermediary in AIF (code walkthrough)
Microsoft Whitepaper: Developing Extensible Data Security Policies (download)
Microsoft Whitepaper: Using The Policy Framework (download)


Various
10-minute AX 2012 App: WPF (code walkthrough)
10-minute AX 2012 App: Windows Azure (code walkthrough)
10-minute AX 2012 App: Windows Phone 7 PART1 (code walkthrough)
10-minute AX 2012 App: Windows Phone 7 PART2 (code walkthrough)
10-minute AX 2012 App: Windows Phone 7 PART3 (code walkthrough)app.html

For more info - 
http://daxmusings.blogspot.in/p/microsoft-dynamics-ax-2012-developer.html