Updating MSD files programmatically with new SDE connection details

4396
5
04-11-2014 12:59 PM
New Contributor III
Hi,

I am in process of updating ArcSDE server from 9.31 10 10.2. There are lots of MSD files that uses old SDE server connection and need to be updated with correct path and Dataset Names.
I tried using IMSDHelper to update connection string but I am wondering how to update other parameter's for MSD to republish it.

I will highly appreciate any help in this regard.

Thanks,
Sumit
Tags (2)
Reply
0 Kudos
5 Replies
MVP Regular Contributor
You said that you are updating ArcSDE, so your data model should remain the same.  Are you saying "upgrade"?  In fact, with a true upgrade the database name and locations of each feature class and table should all remain the same.  If that is the case, then your MSD should connect just fine to the database after the upgrade.  If you have actually created a new geodatabase, then hopefully the data is still structured the same.  What I would suggest is to open the MSD (or the MXD that was used initially to produce the MSD) such that the layer data sources are broken (e.g., red exclamation points).  This can be done by opening the MSD when the computer is not connected to the network or by stopping your old ArcSDE instance temporarily.  The goal is to get the MSD open so the layers and tables in the TOC are all broken.  Once you have your new SDE connection set up in ArcCatalog, right click on one of your broken layers and pick Repair Data... in order to re-point to the same object class in your upgraded database.  Once you repair one layer, everything else should repair automatically.  Save your MSD from there, or if you've done this in an MXD, then re-generate a new MSD.  Another option, which I've found to be tedious and cumbersome, is to use the Repair MXD Data Connection tool (which works on MSDs too).  Here is a good article that covers the process within Step 1, albeit from Geocortex.
Reply
0 Kudos
New Contributor

how should i open msd file?

thank you

Reply
0 Kudos
Esri Frequent Contributor
Hi!

  Starting at ArcGIS 10.1, Map Server Definition (.msd) files have been replaced with Service Definition Draft (.sddraft) and Service Definition (.sd) files. Every MXD document from which you were able to create an MSD in 9.3.1, you should be able to be able to convert into a Service Definition.
  You can relatively easily use Python to programmatically change your 9.3.1 MXDs and publish them to 10.2.

Updating your mxds (use from a machine running ArcGIS Desktop 10.2):

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project_default.mxd")
mxd.findAndReplaceWorkspacePaths(r"C:\Project\Connection to Default.sde",
                                 r"C:\Project\Connection to Version1.sde")
mxd.saveACopy(r"C:\Project\Project_V1.mxd")
del mxd

(From: http://resources.arcgis.com/en/help/main/10.2/index.html#/Updating_and_fixing_data_sources_with_arcp...)

Publishing your mxds (also run from a machine running 10.2):

import arcpy

# define local variables
wrkspc = 'C:/Project/'
mapDoc = arcpy.mapping.MapDocument(wrkspc + 'Project_default.mxd')
con = r'GIS Servers\arcgis on MyServer_6080 (admin).ags'
service = 'Default'
sddraft = wrkspc + service + '.sddraft'
sd = wrkspc + service + '.sd'

# create service definition draft
arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'ARCGIS_SERVER', con, True, None)
# analyze the service definition draft
analysis = arcpy.mapping.AnalyzeForSD(sddraft)

# stage and upload the service if the sddraft analysis did not contain errors
if analysis['errors'] == {}:
    # Execute StageService
    arcpy.StageService_server(sddraft, sd)
    # Execute UploadServiceDefinition
    arcpy.UploadServiceDefinition_server(sd, con)
else:
    # if the sddraft analysis contained errors, display them
    print analysis['errors']

(From: http://resources.arcgis.com/en/help/main/10.2/index.html#/AnalyzeForSD/00s30000006p000000/ )


You can also find useful scripts for administering ArcGIS Server here: http://resources.arcgis.com/en/help/main/10.2/#/Scripting_ArcGIS_Server_administration/0154000005p30...


If you are not familiar with ArcGIS Server Data Stores, please have a look at this: http://resources.arcgis.com/en/help/main/10.2/#/About_registering_your_data_with_the_server/01540000...   Data Stores are a concept that did not exist in 9.3.x or 10.  It is important to understand what they do. Data Stores can be created programmatically too.


Ismael Chivite
Reply
0 Kudos
New Contributor III
Hello Ismael,

Thanks for reply, but currently we are using ArcGIS Sever 10.0 and therefore I have to update .Msd files.

So if there an option of programatically updating .Msd files ( not from Mxds)

Thanks,
Ss
Reply
0 Kudos
Esri Frequent Contributor
Hi,

if you are using version 10, you may want to use this forum: http://forums.arcgis.com/forums/9-ArcGIS-Server-%2810.0-and-prior%29-.NET

Ismael
Reply
0 Kudos