Tech

Min blogg är både en privat blogg och en plats där jag sparar intressanta teknikartiklar. På förstasidan hamnar alla artiklar men om man bara är intresserad av min tekniska information så kan man välja rubriken/kategorin Tech. För att prenumerera på Tech, använd denna feed.

Installing a deployable package in Dynamics 365 for Operations using command-line

Today we will be installing a deployable package using command line… this article is mostly for creating a condensed version for my own use… for a complete version please look at the link at the bottom of the page

1. From the Dynamics Server (using RDP) log into https://lcs.dynamics.com and select the correct project.
2. Goto Asset Library and download the package to D:\
3. Goto Properties for the file and unblock it
4. Unzip the file

NOTE: The folder where the files are unziped/stored must not contain spaces

5. Edit the DefaultTopologyData.xml file to look like this (for a onebox environment):

<?xml version=”1.0″ encoding=”utf-8″?>
<TopologyData xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>
   <Name>AX topology</Name>
   <MachineList>
     <Machine>
       <Name>localhost</Name>
       <ServiceModelList>
         <string>AOSService</string>
         <string>ALMService</string>
         <string>BIService</string>
         <string>DevToolsService</string>
         <string>DIXFService</string>
         <string>DocumentRoutingAgent</string>
         <string>MROneBox</string>
         <string>PayrollTaxModule</string>
         <string>PerfSDK</string>
         <string>ReportingService</string>
         <string>RetailCloudPos</string>
         <string>RetailHQConfiguration</string>
         <string>RetailSDK</string>
         <string>RetailSelfService</string>
         <string>RetailServer</string>
         <string>RetailStorefront</string>
         <string>SCMSelfService</string>

    <!– DefaultTopologyData are only for dev vhd, which we only support AOS update–>
         <!– Create a new topology data for your Cloud AX topology–>
       </ServiceModelList>
     </Machine>
   </MachineList>
   <BackupScript>
     <FileName />
     <Automated>false</Automated>
     <Description>Please backup your environment now, set this step to complete once you finished backup</Description>
   </BackupScript>
</TopologyData>

6. Run these commands to install the file:

AXUpdateInstaller.exe generate -runbookid=name-runbook -topologyfile=DefaultTopologyData.xml -servicemodelfile=DevInstallServiceModelData.xml -runbookfile=name-runbook.xml
AXUpdateInstaller.exe import -runbookfile=”name-runbook.xml”
AXUpdateInstaller.exe execute -runbookid=”name-runbook”

Links:
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/deployment/install-deployable-package

Configuring access for mobile warehousing app in Dynamics 365 for Operations

Today I am setting up the mobile warehouse app in Dynamics 365 for Operations… there is a very nice Wiki article here with the walkthrough but I am doing a slightly condensed version.

Edit 180108: Step has been edited to work in the new portal

  1. Go to the azure portal. In Azure Active Directory – App Registrations create a web application for the warehouse portal

    Name: WhatEverYouWant
    Application Type: Web app/API
    Sign-on URL: https://[theURLforyourdynamicsinstance]/oauth

  2. Open the application to edit it
  3. Verify Application ID. If you create the Application in the new new portal it will auto generate an AppID which is random. If you use the old portal to create the application you will have to add the App ID URI. Make sure that this URI is NOT your Dynamics 365 for operations URL because this will break for instance Excel Add-in and Management Reporter. For more information look here
  4. Go to Required Permissions and click Add
  5. Select the API called Microsoft Dynamics ERP (Microsoft.ERP)
  6. Under Permissions to other applications click add application and add Microsoft Dynamics ERP
  7. Add the following permissions

    Access Dynamics AX online as organization users
    Access Dynamics AX data
    Access Dynamics AX Custom Service

  8. Go to API Access – Keys, enter the name for your new key and set a duration. When you click save you will get the key. Please remember to copy and save it some where because it will not be visible later.
  9. Now you need to save the ClientID (Old Portal)/Application ID (New Portal) for later.
  10. Log into Dynamics 365 for Operations and go to System Administration – Users and create a new user (in my case called WMAPP. The email address can be anything since it will never be used. The user needs these roles

    Warehouse mobile device user

  11. Now we need to associate the user to the AD Application which is done on System Administration – Setup – Azure Active Directory applications. Here we paste the App ID/ClientID from before and select the user we created. Click Save and you are done.
  12. Install the App from app store and enter these settings:

    SNAGHTML12dda1b

    1. Azure Active Directory ID: AppID/CleintID from step 9
    2. Azure Active Directory Client Secret: The key from step 8
    3. Azure Active Directory Resource: Your Dynamics 365 URL
    4. Azure Active Directory Tennant: https://login.windows.net/yourADtennant
    5. Company: Dynamics 365 for Operations Legal Entity

Links:
https://ax.help.dynamics.com/en/wiki/install-and-configure-dynamics-365-for-operations-warehousing/

Using the Retail Reprovisioning tool for Dynamics 365 for Operations

When you do any kind of copying between environments in Dynamics there are some settings which are copied that are actually wrong for the destination environment. To fix these you need to run a tool called Retail Reprovisioning tool (also called Environment retargeting tool)

At the beginning this was only supposed to be run for environments actively using the Retail Components. The recommendation at the moment (2017-11-29) is to run it for every environment since al of the actually contains Retail components.

1. To make sure that you have the latest version of the tool go to LCS – Asset Library. Go to Software Deployable Packages – Import  and Select the latest Environment Reprovisioning tool.

2. The next step is different depending on which type of environment you are using.

If you are using a 2-tier environment; go to the environment, select Maintain and  Apply Updates. Select the Environment Reprovisioning tool and click Apply. Continue to Step 5

If you are using a Dev environment you are not able to deploy using LCS and you will have to deploy from command line according steps 3 – 4

3. Unblock the downloaded file by Right-clicking the file and going to Properties – General Unblock for the fil

4. Extract the file to a temporary directory

Install using these command lines:

AXUpdateInstaller.exe list

Fix the DefaultTopologyData.xml and make it look like this:

<?xml version=”1.0″ encoding=”utf-8″?>
<TopologyData xmlns:xsd=”
http://www.w3.org/2001/XMLSchema” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>
   <Name>AX topology</Name>
   <MachineList>
     <Machine>
       <Name>localhost</Name>
       <ServiceModelList>
         <string>RetailServer</string>
         <string>ALMService</string>
         <string>AOSService</string>
         <string>BIService</string>
         <string>DevToolsService</string>
         <string>DIXFService</string>
         <string>DocumentRoutingAgent</string>
         <string>MROneBox</string>
         <string>PayrollTaxModule</string>
         <string>PerfSDK</string>
         <string>ReportingService</string>
         <string>RetailCloudPos</string>
         <string>RetailHQConfiguration</string>
         <string>RetailSDK</string>
         <string>RetailSelfService</string>
         <string>RetailStorefront</string>
         <string>SCMSelfService</string>
         <!– DefaultTopologyData are only for dev vhd, which we only support AOS update–>
         <!– Create a new topology data for your Cloud AX topology–>
       </ServiceModelList>
     </Machine>
   </MachineList>
   <BackupScript>
     <FileName />
     <Automated>false</Automated>
     <Description>Please backup your environment now, set this step to complete once you finished backup</Description>
   </BackupScript>
</TopologyData>

Generate The Runbook
AXUpdateInstaller.exe generate -runbookid=[runbookID] -topologyfile=[topologyFile] -servicemodelfile=[serviceModelFile] -runbookfile=[runbookFile]
AXUpdateInstaller.exe import -runbookfile=[runbookFile]

Verify the runbook

AXUpdateInstaller.exe list

Execute the runbook

AXUpdateInstaller.exe execute -runbookid=[runbookID]

Post Steps:

5. After the retargeting tool is run you need to run these four steps

a. Open the “Retail Parameters” form, and press the “Initialize” link under the “General” tab. Answer “Yes” to the prompt. This will provide any new Retail seed data.

clip_image001

b. Open the “Initialize Retail Scheduler” form, and run it with “delete existing configuration” set to “Yes“.

c. Restart the “Microsoft Dynamics AX Batch Service” on all AOS VMs. This will update any cached connection credentials that may be used when running a CDX data sync. (done by DSE if PROD => you need to raise a ticket)

d. Navigate to the “Channel Database” form and run a CDX 9999 sync (full sync). This should succeed if everything is properly configured for Retail.

6. Sometimes there is issues with some columns in some tables in the channel database looses their setting for full text indexing (this seems to be an effect of the BacPac procedure when sopying to and from an Azure Environment), this results in not being able to search in for instance MPOS. To verify this you can use this script:

SELECT
SCHEMA_NAME(t.schema_id) as TableSchema,
       t.name AS TableName,
       c.name AS CatalogName ,
       i.name AS UniqueIdxName,
       cl.name AS ColumnName,
COLUMNPROPERTY(t.object_id, cl.name, ‘IsFulltextIndexed’) as IsFullTextEnabledOnTable,
          fi.is_enabled AS isEnabledOnColumn
FROM
sys.tables t
INNER JOIN
sys.fulltext_indexes fi
ON
    t.[object_id] = fi.[object_id]
INNER JOIN
sys.fulltext_index_columns ic
ON
    ic.[object_id] = t.[object_id]
INNER JOIN sys.columns cl ON
        ic.column_id = cl.column_id
AND ic.[object_id] = cl.[object_id]
INNER JOIN
sys.fulltext_catalogs c
ON
    fi.fulltext_catalog_id = c.fulltext_catalog_id
INNER JOIN
sys.indexes i
ON
        fi.unique_index_id = i.index_id
AND fi.[object_id] = i.[object_id]
where c.name like ‘COMMERCEFULLTEXTCATALOG’
order by Tablename ASC

look for the ones having a ‘0’ in any column and fix them by runing:

ALTER FULLTEXT INDEX
ON [ax].tablename
ENABLE

ALTER FULLTEXT INDEX
ON [ax].tablename
SET CHANGE_TRACKING=MANUAL;
GO

ALTER FULLTEXT INDEX ON [ax].tablename START FULL POPULATION;
GO

ALTER FULLTEXT INDEX
ON [ax].tablename
SET CHANGE_TRACKING=AUTO;
GO

Links:
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/deployment/install-deployable-package

Retail servicing data is not present in the RetailServer web.config when running Retail Retargeting tool

Thi is an issyue we have noticed on especially new environments that we have refreshed with a database from an existing Retail Enable environment. After refreshing the database we need to run the retargeting tool to make sure that all settings are corrected.

When the tool is run it fails at step 3 and when we look in the Step3RetargetRetailServer-logfile we find this:

12/6/2017 9:35:52 AM:     – Trying to get information of the website – AOSService …
Unexpected error. Microsoft.Dynamics.ApplicationPlatform.Environment.Settings.ConfigurationKeyNotFoundException: No setting keys found for prefix ‘CertificateHandler’.
    at Microsoft.Dynamics.ApplicationPlatform.Environment.Settings.BaseConfigSetting.GetSettingsForPrefix(String prefix)
    at ConfigEncryptor.Program.Main(String[] args).
12/6/2017 9:35:52 AM:
PSMessageDetails      :
Exception             : System.Management.Automation.RuntimeException: Retail servicing data is not present in the
                         RetailServer web.config, please contact DSE team.
TargetObject          : Retail servicing data is not present in the RetailServer web.config, please contact DSE team.
CategoryInfo          : OperationStopped: (Retail servicin…ntact DSE team.:String) [], RuntimeException
FullyQualifiedErrorId : Retail servicing data is not present in the RetailServer web.config, please contact DSE team.
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, F:\DeployablePackages\a2f41617-591e-45c9-bce4-1934c1b17ca6\RetailServer\scrip
                         ts\RetargetRetailServer.ps1: line 299
                         at <ScriptBlock>, <No file>: line 3
                         at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
12/6/2017 9:35:52 AM: Executed:
F:\DeployablePackages\a2f41617-591e-45c9-bce4-1934c1b17ca6\RetailServer\scripts\RetargetRetailServer.ps1
Exiting with error code .

This error is due to missing information in the Web.Config file for Retail. Fortunately there is a fairly easy fix… there is a script in the Retail Retargeting tool called Update-RetailServicingInformation.ps1 which populates the web.config file with the correct information. The parameters you will need to provide is the database name which you can find in SQL Server Management Studio and the SQL Server name. The server name for OneBox Environments is Localhost. For Tie-2 and up you will need to provide the Azure SQL name which you can find in LCS, don´t forget to add database.windows.net to make it a FQDN

/Johan

Azure SQL SqlPackage error

Today I tried to do a restore of database to an Azure DB in a Dynamics 365 for Operations environment. When I ran SQLPackage.exe I got the following error:

‘Unable to connect to master or target server ‘AxDB_New’. You must have a user with the same password in master or target server ‘AxDB_New’

The issue here is that the version of SQL Management Studio that is provided in the Azure VM is version 16 and Azure SQL requires version 17… with that background I am not convinced that the error message is totally relevant…

The solution is to upgrade Management Studio to the latest Version.

image

/Johan

Providing a clean database in upgrade mode for AX 2012

When we upgrade to AX 2012 the destination database needs to be in “upgrade mode” othewise the upgrade checklist it not triggered correctly. This can be done in one of two ways… either you check “Register this database for Upgrade” when you set up the AOS… this implies that you actually set up a new AOS. If you do not want to do that you can also do this:

1. Start SQL Management Studio and run this script:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[SETUPVERSIONPROC] AS SELECT ‘6.0.947.0’
GO
DELETE FROM SysSetupLog
WHERE NAME = ‘SysCheckList_Setup’
OR NAME LIKE ‘SysCheckList_Up%’

Links
https://blogs.msdn.microsoft.com/axsupport/2012/11/16/ax2012-upgrades-setting-a-clean-ax2012-database-to-start-with-the-upgrade-check-list-and-not-the-initialization-check-list/

Running out of space on a Dynamics 365 for Operations Vm in Azure–Part 1

When setting up environments for Dynamics 365 for Operation in Azure you are using a tool called LCS (Life Cycle Services). This allows you to set up VMs in different sizes and once the are up it does not allow you to change them. When using the VMs they tend to, sooner or later, fill up and run out of disk space. There are two main ways to fix this… clean up or make the disk bigger (this will be handled in another article which I will link here). In this article we will look at things you can clean up.

1. Remove files in C:\TEMP
Note: Do NOT remove the C:\DIXF folder… that will make DIXF fail. If you remove it, by mistake, you will have to recreate it and manually set permissions on it.

2. You can also clean out files in C:\MonAgentData\SingleAgent\Tables\. To do this you first have to stop the Monitoring Agent Service.

Bye for today

Links
https://devserra.wordpress.com/2016/03/03/ax7-release-hd-space-on-your-ctp8-vm/

Detailed Version Information in LCS

When contacting Microsoft Support about Dynamics 365 for Operations they often ask you for the version information for an environment. We have been having an issue with seeing it for our Cloud Hosted Environments… it simply was not there:

SNAGHTML9e3aa91

I finally found a way to fix this and it is Very Simple (onece you know it)

Go to the adress bar in your browser… At here end of your URL you will find:

&IsDiagnosticsEnabledEnvironment=false

change it to:

&IsDiagnosticsEnabledEnvironment=true

and presto!!!

SNAGHTML9e78d61

/Johan

Backup Azure SQL database

In working with Dynamics 365 for operations one is exposed to Azure SQL. Azur SAL works a bit differently than the “regular old” SQL and one of those areas is backup.

To backup a database in Azure SQL I use one of two methods:

1. Create a copy of the table in the same SQL Server

CREATE DATABASE [sourcedb] AS COPY OF [destinationdb]

This operation is performed asynchronously and you will need to verify that the job is done before you continue. This can be done with this command:

SELECT * FROM sys.dm_database_copies

Note: you need to have selected the master database when you run the backup. Otherwise you will not be able get an exclusive lock on the database and you will get the following error: Msg 42019

To find what is locking the database you can use:

SELECT * FROM sys.dm_exec_sessions
KILL [session ID]

2. Use SqlPackage to create an export in the form of a BacPac file

cd C:\Program Files (x86)\Microsoft SQL Server\130\DAC\bin
SqlPackage.exe /a:export /ssn:<server>.database.windows.net /sdn:<SourceDB> /tf:<filedestination> /p:CommandTimeout=1200 /p:VerifyFullTextDocumentTypesSupported=false /sp:<sql password> /su:<sql user>


/Johan