Configuring a LCS Repository for Electronic Reporting in Dynamics 365 for Finance and Operations

In Dynamics 365 for Finance and Operations, Microsoft provides a large repository for Electronic Reports. These cover a lot of scenarios but for those scenarios that requires custom reports you can use LCS to store these in order to share them between environments.

This requires a configuration in D365

First you need to add a configuration provider:

  1. In D365FO search for “Electronic Reporting”
  2. In the right click Configuration Providers

  3. Click New, Give it a Name and a URL and click save
  4. Back in the GER Workspace select the new provider and click Repositories

  5. On the Configuration repositories screen click Add – LCS and Create Repository. Select the correct LCS project and click OK.


    Note: Sometimes you need to make a connection to LCS. To do that click “Click here to connect to LifeCycle Services”. This is done in a separate tab. When it is done switch back to the previous tab and click OK. If you get an error, try again.

  6. To look at the reports in the repository, select it and click Open. You will see the reports stored in the LCS repository.

  7. You are also able to see them directly in LCS, in the Asset Library. If you are working as a consultant this report can then be saved to your personal Asset Library and shared with your colleagues

  8. To give your organization access to your custom report, go to the Shared Asset Library, select it and click Publish

Resetting the DataMart in Financial Reporting for Dynamics 365 for Finance and Operations

There is a universal solution for most problems in Financial Reporting (used to be Management Reporter) and that is to reset the DataMart. The DataMart is an internal data warehouse for Financial Reporting and when something goes wrong it is usually because of bad data in the DataMart. Another reason for resetting it when you do a refresh of the transaction database in D365/AX. Here is how you do it.

  1. In D365 search for “Financial Reports”
  2. Depending on if you see reports or not either select a report and click edit or click new. This will open the Report Designer. Note that you will need to enable pop-ups. Also note that if you are doing this in Chrome you will need an extension called ClickOnce in order to run the designer.
  3. You will need to log in using your Dynamics Account.
  4. Choose a default company /which does not really matter for this operation)
  5. If there are any open report definition close it

  6. Go to Tools – Reset Data Mart…
  7. Check Reset data mart and select the correct reason for the reset

  8. Click OK

    The Data Mart is now reset and filled with fresh data.

  9. Wait for the reset to finish

  10. When all lines have Status RanToCompletion the reset is done.

Setting a Dynamic 365 for Operations cloud hosted environment in Maintenance mode

Some configurations in Dynamics requires you to be in Maintenance Mode. Some of these are:

  • Activating dimensions
  • Changing license keys
  1. Log into the VM using RDP
  2. Start an elevated command prompt
  3. Go to K:\AosService\PackagesLocalDirectory\Bin\ (in this case K is the service volume)
  4. För följande:
    Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir K:\AosService\PackagesLocalDirectory --bindir K:\AosService\PackagesLocalDirectory\Bin --sqlserver . --sqldatabase axdb --sqluser  --sqlpwd [sqlpassword] --setupmode maintenancemode --isinmaintenancemode true
  5. Run IISRESET

To set it back run this

Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir K:\AosService\PackagesLocalDirectory --bindir K:\AosService\PackagesLocalDirectory\Bin --sqlserver . --sqldatabase axdb --sqluser  --sqlpwd [sqlpassword] --setupmode maintenancemode --isinmaintenancemode false

and then IISRESET

Links:
https://community.dynamics.com/365/financeandoperations/b/ax2012codingaxclated/archive/2018/06/22/d365fo-maintenance-mode-importing-license-file-isv-var-add-on-license-import

Renaming a OneBox Dev environment

Hi

Tonight I helped one of my developer colleagues who had issues with one of his DEV environments. The issue was that he had renamed the VM (you cannot have multiple machines in Azure DevOps with the same name). The problem was that he had not completed all the steps that is required to rename so it was behaving a bit weird.

First of all we were not able to connect to Reporting Services Configuration Manager. The solution was unfortunately not very logical… In the onebox environment there is a couple of SQL components installed from different SQL Server Versions:

If you use the wrong SSRS Configuration Manager it is not able to connect to the SSRS Server and get the error message: No report servers were found

The correct version is 2016! Completely logical… NOT!

When this was done we just followed this guide to complete the rename and all is well 🙂

/Johan

Links:
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/migration-upgrade/vso-machine-renaming
http://www.alexondax.com/2017/05/what-i-do-to-rename-d365-virtual.html
https://community.dynamics.com/365/financeandoperations/f/765/t/269137

Uninstalling Excel Addin

This one was an annoying one…

I had to help a customer uninstall the Excel addin for Dynamics 365 for Operations. This should be a simple task (everything is if you know how to do it). So I went into Excel Add-ins using File – Options – Add-Ins… No Dynamics Excel addin:

WFT!!! A nice person then showed me that there is another place for Excel Addins (obviously)… You go to Insert – My Add-ins… Presto!

/Johan

Blocking sessions in Azure SQL

Some environments in Dynamics 365 for Finance and Operations are using Azure SQL. In LCS you can see blocked sessions for the environment but you are not able to do anything about them. To solve the issue you need to log into one of the AOSes using RDP and start Management Studio.

The issue in SMSS when sonnecting it to Azure SQL is that you do not have assess to Activity Monitor… you need to solve the issue using T-SQL.

In order to find the blocking session, run this query:

SELECT
    blocking_session_id AS BlockingSessionID,
    session_id AS VictimSessionID,
   
    (SELECT  FROM sys.sysprocesses
     CROSS APPLY sys.dm_exec_sql_text([sql_handle])
     WHERE spid = blocking_session_id) AS BlockingQuery,
   
     AS VictimQuery,
    wait_time/1000 AS WaitDurationSecond,
    wait_type AS WaitType,
    percent_complete AS BlockingQueryCompletePercent
FROM sys.dm_exec_requests
CROSS APPLY sys.dm_exec_sql_text([sql_handle])
WHERE blocking_session_id > 0

To kill the blocking sessions

Kill [SessionID]

That is it…

Note that when you kill a session in SQL the server rolls the transactions back and that might take some time

/Johan

Problems accessing the /reports website in Dynamics 365 VMs

Hi

Today I had an issue trying to access the classic reports folder for SSRS in a Dynamics 365 for Finance and Operations VM hosted in Azure. When connecting to the site we used http://[VMname]/reports and all we get is a login prompt.

This one was quite easy… Just fire up the Reporting Services Configuration Manager, goto Web Portal URL and click Apply to configure it

And that is it!

Happy weekend

/Johan

Copy database from a OneBox environment to an Azure Sql Environment

Most of this post is a copy of the Microsoft Article (which is referenced below) but with my remarks, clarifications adn some changes for making the process easier.

1. Create a Backup copy of the Source database

BACKUP DATABASE [AxDB] TO DISK = N'D:\Backups\axdb_original.bak' WITH NOFORMAT, NOINIT, NAME = N'AxDB_golden-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10
GO
RESTORE DATABASE [AxDB_CopyForExport] FROM DISK = N'D:\Backups\axdb_original.bak' WITH FILE = 1, MOVE N'AXDBBuild_Data' TO N'F:\MSSQL_DATA\AxDB_CopyForExport.mdf', MOVE N'AXDBBuild_Log' TO N'G:\MSSQL_LOGS\AxDB_CopyForExport_Log.ldf', NOUNLOAD, STATS = 5

Note: You need to change the paths for the database files

2. Prepare YOUR COPY of the database for moving to Azure SQL

update sysglobalconfiguration set value = 'SQLAZURE' where name = 'BACKENDDB' 
update sysglobalconfiguration set value = 1 where name = 'TEMPTABLEINAXDB'
drop procedure XU_DisableEnableNonClusteredIndexes
drop schema [NT AUTHORITY\NETWORK SERVICE]
drop user [NT AUTHORITY\NETWORK SERVICE]
drop user axdbadmin
drop user axdeployuser
drop user axmrruntimeuser
drop user axretaildatasyncuser
drop user axretailruntimeuser
drop user axdeployextuser

3. Export the prepared database to a BacPac file

cd C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\
md D:\Exportedbacpac
SqlPackage.exe /a:export /ssn:localhost /sdn:AxDB_CopyForExport /tf:D:\Exportedbacpac\my.bacpac /p:CommandTimeout=1200 /p:VerifyFullTextDocumentTypesSupported=false

Note: This operation will take quite a while

4. Copy the bacpac file to the destination server
Note: If you have a large file you can use an Azure Storage Blog

5. Import the bacpac as a new database

cd C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\
SqlPackage.exe /a:import /sf:C:\Temp\my.bacpac /tsn:azuresqlserver.database.windows.net /tu:sqladmin /tp:<passwordforsqladmin> /tdn:AxDB_New /p:CommandTimeout=1200 /p:DatabaseEdition=Premium /p:DatabaseServiceObjective=P2

Note: This operation will take quite a while

6. Update the database with users, passwords and some other settings using the script below:

CREATE USER axdeployuser FROM LOGIN axdeployuser
EXEC sp_addrolemember 'db_owner', 'axdeployuser'

CREATE USER axdeployextuser WITH PASSWORD = '<password from LCS>'
IF EXISTS (select * from sys.database_principals where type = 'R' and name = 'DeployExtensibilityRole')
BEGIN
EXEC sp_addrolemember 'DeployExtensibilityRole', 'axdeployextuser'
END

CREATE USER axdbadmin WITH PASSWORD = '<password from LCS>'
EXEC sp_addrolemember 'db_owner', 'axdbadmin'

CREATE USER axruntimeuser WITH PASSWORD = '<password from LCS>'
EXEC sp_addrolemember 'db_datareader', 'axruntimeuser'
EXEC sp_addrolemember 'db_datawriter', 'axruntimeuser'

CREATE USER axmrruntimeuser WITH PASSWORD = '<password from LCS>'
EXEC sp_addrolemember 'ReportingIntegrationUser', 'axmrruntimeuser'
EXEC sp_addrolemember 'db_datareader', 'axmrruntimeuser'
EXEC sp_addrolemember 'db_datawriter', 'axmrruntimeuser'

CREATE USER axretailruntimeuser WITH PASSWORD = '<password from LCS>'
EXEC sp_addrolemember 'UsersRole', 'axretailruntimeuser'
EXEC sp_addrolemember 'ReportUsersRole', 'axretailruntimeuser'

CREATE USER axretaildatasyncuser WITH PASSWORD = '<password from LCS>'
EXEC sp_addrolemember 'DataSyncUsersRole', 'axretaildatasyncuser'

ALTER DATABASE SCOPED CONFIGURATION  SET MAXDOP=2
ALTER DATABASE SCOPED CONFIGURATION  SET LEGACY_CARDINALITY_ESTIMATION=ON
ALTER DATABASE SCOPED CONFIGURATION  SET PARAMETER_SNIFFING= ON
ALTER DATABASE SCOPED CONFIGURATION  SET QUERY_OPTIMIZER_HOTFIXES=OFF
ALTER DATABASE <imported database name> SET COMPATIBILITY_LEVEL = 130;
ALTER DATABASE <imported database name> SET QUERY_STORE = ON;

update [dbo].[SYSSERVICECONFIGURATIONSETTING]
set value =''
where name = 'TENANTID'

update dbo.POWERBICONFIG
set TENANTID = ''

update dbo.PROVISIONINGMESSAGETABLE
set TENANTID = ''

Note: Use these SQL queries to get the TENANTID:
select * from [dbo].[SYSSERVICECONFIGURATIONSETTING]
where name = 'TENANTID'
select TENANTID from dbo.POWERBICONFIG
select TENANTID from dbo.PROVISIONINGMESSAGETABLE

7. Stop services locking the original database

  • World wide web publishing service (on all AOS computers)
  • Microsoft Dynamics 365 for Finance and Operations Batch Management Service (on non-private AOS computers only)
  • Management Reporter 2012 Process Service (on business intelligence [BI] computers only)

Note: this needs to be done on all servers for the environment

8. Run this script to switch the databases

ALTER DATABASE [axdb_123456789] MODIFY NAME = [axdb_123456789_original]
ALTER DATABASE [importeddb] MODIFY NAME = [axdb_123456789]

9. Start services locking the original database

  • World wide web publishing service (on all AOS computers)
  • Microsoft Dynamics 365 for Finance and Operations Batch Management Service (on non-private AOS computers only)
  • Management Reporter 2012 Process Service (on business intelligence [BI] computers only)

10. Syncronize the database

F:
cd F:\AosService\WebRoot\bin
Microsoft.Dynamics.AX.Deployment.Setup.exe -bindir "F:\AosService\PackagesLocalDirectory" -metadatadir F:\AosService\PackagesLocalDirectory -sqluser axdbadmin -sqlserver <azure sql database server name>.database.windows.net -sqldatabase <database name> -setupmode sync -syncmode fullall -isazuresql true -sqlpwd <sql password> >log.txt 2>&1

11. If the environment is running Retail you will need to run the Retail Reprovisioning tool, see instructions in this document

12. Reset the financial Database using these instructions

Note: I have noticed that some integrations are having problems accessing some DLLs after a refresh. This is usually solved by a restart of the environment. To do this easier we usually do it from LCS

Links:
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/database/copy-database-from-sql-server-to-azure-sql
Resetting the financial reporting data mart after restoring a database.

Copy database from a OneBox environment to another OneBox Environment

This document is a check-list I have compiled on moving a database from one OneBox environment to another. Microsoft does not have a document for this scenario so I have compiled information from multiple blog posts.

1. Create a Backup copy of the Source database

2. Move the Database to the destination environment and restore it there

3. Stop the AX Services

  • World wide web publishing service (on all AOS computers)
  • Microsoft Dynamics 365 for Finance and Operations Batch Management Service
    (on non-private AOS computers only)
  • Management Reporter 2012 Process Service (on business intelligence [BI]
    computers only)

4. Rename the OLD database to AxDB_ORIG_TodaysDate and rename the newly restored database to AxDB.

5. Start the services that was stopped in Step 3 above

6. Sync the Database using either Visual Studio or this command from an elevated command prompt:

K:<br />
cd K:\AosService\WebRoot\bi<br />
Microsoft.Dynamics.AX.Deployment.Setup.exe -bindir "K:\AosService\PackagesLocalDirectory" -metadatadir K:\AosService\PackagesLocalDirectory -sqluser axdbadmin –sqlserver localhost -sqldatabase AxDB -setupmode sync -syncmode fullall -isazuresql false -sqlpwd <sql password> >log.txt 2>&1

Note: K is the Service Volume

Verify that there are no errors in log.txt

7. I the environment is running Retail you will need to run the Retail Reprovisioning tool in this document.

8. Reset the Financial Reporting Database according to this document.

Links
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/analytics/reset-financial-reporting-datamart-after-restore
http://blog.johanpersson.nu/?p=2684

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