Select to view content in your preferred language

Update ArcGIS Server Services after SQL Server Instance Change

12337
66
06-09-2022 10:09 PM

Update ArcGIS Server Services after SQL Server Instance Change

You may need to migrate your SQL Server geodatabase to a new server.  For example, say you’re upgrading from SQL Server 2016 to SQL Server 2019, and the 2019 instance is on a new server.  The geodatabase migration can be easy enough with a database backup/restore, but what about updating your ArcGIS Server services?  If the services are referencing data from your enterprise geodatabase, the services will use the SQL instance name.  To fix this, you can re-map the data sources in your ArcGIS Pro Projects and/or MXDs, then republish the services.  However, what if you have dozens and dozens of services?  This could be extremely time consuming.  Instead, you can use the workflow below to update the services for you.

Scenario:

A SQL Server instance is being upgraded from 2016 to 2019.  The 2016 instance resides on server PS0014736, and the new 2019 instance resides on server PS0014737.  Services referencing data from the GISDATA geodatabase on PS0014736 have been published to ArcGIS Server:

JakeSkinner_0-1654837338241.png

Below is the workflow to follow so services do not have to be republished.

Workflow:

Before proceeding with the below steps, create a backup of ArcGIS Server, and make a copy of the \arcgiserver\config-store and \arcgisserver\directories\arcgissystem\arcgisinput directories.

1.  Restore the GISDATA geodatabase to the new SQL Server 2019 instance on PS0014737.

2.  Register the GISDATA geodatabase from the new SQL Server 2019 instance (PS0014737) as a Data Store

JakeSkinner_1-1654837338267.png

3.  Log into ArcGIS Server Administrator to get the DSIDs of the previous (PS0014736) and new (PS0014737) Data Store connections

  1. Navigate to data > items > enterpriseDatabases
  2. Under Child Items, click on each child item for the data store connections:

           

JakeSkinner_2-1654837338280.png

c.  Copy the ID value.  This is the DSID

           

JakeSkinner_3-1654837338286.png

4.  Stop the ArcGIS Server service

5.  Update the # Variables in the below script

Variable Name

Description

arcgisInputDirectory

ArcGIS Server arcgisinput directory

arcgisConfigStoreDirectory

ArcGIS Server config-store directory

previousInstance

Previous SQL Server Instance

newInstance

New SQL Server Instance

previousDSID

Previous SQL Server Instance DSID

newDSID

New SQL Server Instance DSID

tempDirectory

Temporary Director to write files to

 

 

import arcpy, os, zipfile, shutil, re
from zipfile import ZipFile

# Variables
arcgisInputDirectory = r'C:\arcgisserver\directories\arcgissystem\arcgisinput'      # ArcGIS Server arcgisinput directory
arcgisConfigStoreDirectory = r'C:\arcgisserver\config-store\services'               # ArcGIS Server config-store directory
previousInstance = 'PS0021465'                                                      # Previous SQL Server instance
newInstance = 'PS0021475'                                                           # New SQL Server Instance
# named instance would be r'PS0021465\\\\gis'
previousDSID = '2cf24591-2e4a-4877-aac0-25ac4c2c0fd4'                               # Previous SQL Server Instance DSID
newDSID = 'c607988a-7494-472e-a590-26c200c7d2b8'                                    # New SQL Server Instance DSID
tempDirectory = arcpy.env.scratchFolder                                             # Temp Directory


# Function to zip MSD
def zipMSD(extractLocation, tempDirectory):
    '''Function to zip directory to create new MSD'''

    newMSDFile = os.path.join(tempDirectory, f"{msdFileName}")
    with zipfile.ZipFile(newMSDFile, 'w', zipfile.ZIP_DEFLATED) as msdzip:
      length = len(extractLocation)

      for root, dirs, files in os.walk(extractLocation):
          folder = root[length:] # path without "parent"
          for file in files:
              msdzip.write(os.path.join(root, file), os.path.join(folder, file))

    return newMSDFile

# Function to update MSD
def updateMSD(service, xmlJSONFile):
    servicesList.append(service)

    # Open XML/JSON File and replace DSID
    print("\tReading file and updating")
    with open(xmlJSONFile, 'r') as file:
        filedata = file.read()
        filedata = filedata.replace(previousDSID, newDSID)
        if re.search(previousInstance, filedata, re.IGNORECASE):
            filedata = re.sub(rf'\b{previousInstance}\b', newInstance, filedata, flags=re.IGNORECASE)
    # Write to new XML/JSON File
    print("\tWriting new file")

    with open(xmlJSONFile, 'w') as file:
        file.write(filedata)

    # Zip directory to create updated MSD
    print("\tCreating new updated MSD file")
    zipMSD(extractLocation, tempDirectory)

    # Replace original MSD file with updated MSD
    print("\tReplacing original MSD file")
    msdFileLocation = os.path.dirname(msdFile)
    shutil.move(os.path.join(tempDirectory, msdFileName),
                os.path.join(msdFileLocation, msdFileName))

# Create list of services that are updated
servicesList = []

# Iterate arcgisinput directory to update MSD file
for root, dirs, files in os.walk(arcgisInputDirectory):
    for name in files:
        if '.msd' in name:
            msdFileName = name
            service = root.split('.')[0].split('\\')[-1]
            msdFile = os.path.join(root, name)
            extractLocation = os.path.join(tempDirectory, service)
            os.mkdir(extractLocation)
            with ZipFile(msdFile, 'r') as zipObj:
                # Extract all the contents of MSD file in temp directory
                print(f'\nExtracting {service} file to temp directory')
                zipObj.extractall(extractLocation)
            # If published from ArcGIS Pro
            if 'p20' in root or 'p30' in root:
                if os.path.isdir(os.path.join(extractLocation, 'map')):
                    mapDirectory = os.path.join(extractLocation, 'map')
                else:
                    mapDirectory = os.path.join(extractLocation, 'layers')
                # Update XML File
                for root, dirs, files in os.walk(mapDirectory):
                    for name in files:
                        if 'map.xml' not in name and '.json' not in name:
                            xmlFile = os.path.join(root, name)
                            updateMSD(service, xmlFile)
                        elif '.json' in name:
                            for root, dirs, files in os.walk(extractLocation):
                                for name in files:
                                    if '.json' in name:
                                        jsonFile = os.path.join(root, name)
                                        updateMSD(service, jsonFile)

            # If published from ArcMap
            elif 'v101' in root:
                mapDirectory = os.path.join(extractLocation, 'layers')
                # Update XML File
                for root, dirs, files in os.walk(mapDirectory):
                    for name in files:
                        if 'layers.xml' not in name:
                            servicesList.append(service)
                            xmlFile = os.path.join(root, name)
                            # Open XML File and replace DSID
                            print("\tReading XML file and updating")
                            with open(xmlFile, 'r') as file:
                                filedata = file.read()
                                filedata = filedata.replace(previousDSID, newDSID)
                            # Write to new XML File
                            print("\tWriting XML file")
                            with open(xmlFile, 'w') as file:
                                file.write(filedata)

                            # Zip directory to create updated MSD
                            print("\tCreating new updated MSD file")
                            zipMSD(extractLocation, tempDirectory)

                            # Replace original MSD file with updated MSD
                            print("\tReplacing original MSD file")
                            msdFileLocation = os.path.dirname(msdFile)
                            shutil.move(os.path.join(tempDirectory, msdFileName),
                                        os.path.join(msdFileLocation, msdFileName))

            # Remove extracted content in temp directory
            print("Removing extracted content")
            shutil.rmtree(extractLocation)

# Update manifest.json
for service in servicesList:
    for root, dirs, files in os.walk(arcgisConfigStoreDirectory):
        for dir in dirs:
            if dir in [f'{service}.MapServer', f'{service}.FeatureServer']:
                serviceDirectory = os.path.join(root, dir)
                for root, dirs, files in os.walk(serviceDirectory):
                    for name in files:
                        # Copy manifest JSON file
                        if name == 'manifest.json':
                            manifestJSON = os.path.join(root, name)
                            copyManifestJSON = os.path.join(tempDirectory, name)
                            shutil.copyfile(manifestJSON, copyManifestJSON)

                            # Read JSON file
                            with open(copyManifestJSON) as jsonFile:
                                data = jsonFile.read()

                            # If previous instance found in json, replace with new instance
                            if re.search(previousInstance, data, re.IGNORECASE):
                                print(f"\nUpdating {service} manifest.json with new instance info")
                                data = re.sub(rf'\b{previousInstance}\b', newInstance, data, flags=re.IGNORECASE)
                                with open(copyManifestJSON, 'w') as jsonFile:
                                    jsonFile.write(data)

                                print("\tReplacing original manifest.json")
                                shutil.copyfile(copyManifestJSON, manifestJSON)

                            # Remove manifest.json in temp directory
                            os.remove(copyManifestJSON)

print("Finished")

 

6.  Execute the script

7.  After the script executes, start the ArcGIS Server service

 

Results

The services should now reference the new SQL Server instance (PS0014737):

JakeSkinner_4-1654837338327.png

 

To further demonstrate the service updated, parcels were deleted (northeast section) in the new instance before the script was executed.  Shown below is a screen shot of the service before the script was executed and afterwards:

Service referencing original instance (PS0014736):

JakeSkinner_5-1654837338684.png

 

Service referencing new instance (PS0014737):

JakeSkinner_6-1654837339177.png

 

Video

A video of the workflow can be found at the following link.

Notes

It's not necessary to create a new Data Store connection.  You can easily update an existing Data Store connection within ArcGIS Server Manager, or the Settings tab of the Data Store item within Portal if registered via ArcGIS Pro.  However, the Service Workspaces will still show the previous instance information until this script is executed.  For the newDSID variable, you would simply specify the same value as the previousDSID variable.

Attachments
Comments
Brian_Wilson
Honored Contributor

I asked Esri for help with this yesterday so this extremely good timing for me. This is far more detailed information.  I only regret I can't give more than 1 kudo.

 

JakeSkinner
Esri Esteemed Contributor

@Brian_Wilson let me know how the script works out for you.  

Brian_Wilson
Honored Contributor

I ran through it in a debugger and tested.

Pretty interesting things going on down deep in the arcgisinput folder.

The re.search at line 127 and the re.sub would be a big problem for me since the current deployment is single machine and SQL Server runs in the same container. So replacing "cc-gis" with "cc-newserver" will also replace all strings referencing the other components, breaking everything.

Our new deployment will have "cc-gis" and other machines like "cc-gisserver" and "cc-gisdatastore". 

I would need to use a more complete regular expression to avoid a problem. I have not found any manifest files directly referencing the database server so I cannot construct a proper regex. I think it might be using "sde.default" and mapping in the server elsewhere??? I do see references in the MSD files to the ID.

The Esri support guy told me I can change my SQL Server instance by creating an SDE connection doc that points at the new server and then import it on this screen. I will be trying that soon. What could possibly go wrong? I am thinking that if this updates the connection without changing the ID then none of the MSD files should need to change.

BrianWilson7_0-1654972150326.png

I would have made a terrible open heart surgeon. "Wait wait, we need to make a full back up first, and then we need to stop the patient while we do this! Let's get a snapshot and have a virtual copy of the patient ready in case this one fails." (I recall there is a John Varley story along these lines out there.)

 

Brian_Wilson
Honored Contributor

ALL DONE -- follow up -- I did what I mentioned - changed the connection in Server Manager and everything is now working with the new database. My desktop users will need to adjust their MXD and APRX files but the web sites jumped over without a hiccup.

JakeSkinner
Esri Esteemed Contributor

@Brian_Wilson you are right, updating the Data Store connection file updated the data source of the services.  Originally, I tried this with a customer and we both thought the connections were not updated due to Service Workspaces in Server Manager showing the original instance information (i.e. screen shot in the Results section of the document).  The workflow above will update that information.

The replace option on line 127 will only update the manifest.json for a service that contained the previousDSID value.  It will not crawl through every file in the config-store directory/sub-directory updating occurrences of the previous SQL instance.

Brian_Wilson
Honored Contributor

The replace option on line 127 will only update the manifest.json

The problem is not that it will update too many manifests, it's that it's doing a global string replace in the manifest. I tested it to confirm this. In my case since all my servers start with "cc-gis" and the original database server was called "cc-gis", the script will change every occurrence of "cc-gis" to "cc-sqlseserver", so for example, "cc-gisdatastore" will be changed to "cc-sqlserverdatastore" when it should not be changed at all because it's the datastore not the sql server.

It should be possible to construct a better regular expression that only finds the SQL instance. I stopped working on it when the other method worked, else I would contribute an updated regular expression.

I'm just worried someone might try the script without enough testing and break things.

JakeSkinner
Esri Esteemed Contributor

@Brian_Wilson good call on the re.sub expression.  I've updated the script to only update whole words.

GregCarlino2
Regular Contributor

Hi Jake,

I followed the steps listed above and ran the script.  The python log cycled through all of the services and indicated successful completion.  However, upon verifying, it didn't appear to actually have repointed anything toward the new DB.  As in the above case, we are also trying to migrate our Enterprise DB from off the same machine as ArcGIS Server, where it currently resides, onto its own dedicated machine.  Any idea on what might be going wrong?

Thanks,

Greg

Specs:  ArcGIS Enterprise 10.9; SQL Server 2016 (Windows); ArcGIS Pro 2.9.3

JakeSkinner
Esri Esteemed Contributor

@GregCarlino2 did you stop the ArcGIS Server service before executing the script?

GregCarlino2
Regular Contributor

Yes, we stopped ArcGIS Server before running. 

I noticed that there are more comments for certain layers than others, which seemed peculiar.  For example, for the majority of layers, it simply wrote:

Extracting Administrative_Boundary_Layers_050922 file to temp directory
Removing extracted content

Extracting Census_Tracts_2020 file to temp directory
Removing extracted content

Yet, for a handful of layers, it seemed to add more comments:


Extracting Subdivisions_061721 file to temp directory
Reading XML file and updating
Writing XML file
Creating new updated MSD file
Replacing original MSD file
Reading XML file and updating
Writing XML file
Creating new updated MSD file
Replacing original MSD file
Removing extracted content

This also seemed to correspond to whether each service's Workspace Properties were updated within ArcGIS Server Manager.  Yet, even if the properties updated to the new server, they seemed to reflect this change in label only.  All services ceased to load, once we shut down the outgoing SQL Server DB service to confirm, save for one layer that I manually overwrote from ArcGIS Pro, sourcing the new DB, as a sort of control example.

JakeSkinner
Esri Esteemed Contributor

@GregCarlino2 you can update the existing Data Store connection to the new geodatabase connection file and the services will update, however the labels in Server Manager will not.  

As for why the workflow is not working, I can't say for sure.  I would need to further trouble shoot.

GregCarlino2
Regular Contributor

Hi Jake,

One potential cause of our failure might be concerning the correct DSID of the previous Data Store, as it seems I have two:  I'm assuming one is from before we upgraded from our old version of Enterprise (10.6.1), as it has no corresponding Data Store Item in Portal as layers were published from ArcMap; and one from afterward (post 10.7.1), which has a Data Store Item, evidently created once layers started to be published from ArcGIS Pro.  How do we know which one is the correct one to use with the script?  Does this imply that when layers are published, they are encoded with one DSID or the other?  If so, can I run the script once for each DSID, or will that have a deleterious effect?

Thank you,

GregDSIDs.png

JakeSkinner
Esri Esteemed Contributor

@GregCarlino2 the mapsdb_2_ds_5dvlweynyockhtz0 data store is when you register a data store in ArcGIS Pro.  It will create an item in Portal.  If you create the data store connection in ArcGIS Server Manager by going to Site > Data Stores, it will create the data store connection as mapsdb.  

Yes, you can run the script once for each DSID, that should not have an deleterious effects.

TimMinter
Frequent Contributor

Another approach to consider if your team or your administrators have access to Microsoft Active Directory is to create an Alias (CNAME) for the machine your SQL Server is on.  Something like this:

  • IP:  <current IP>
  • Server:  <current server name>
  • Alias (CNAME): Geodata

An event arises wherein you decide to migrate to a more recent SQL Server version.  You complete the migration, one step being to update the Active Directory entry for your Alias(CNAME):

  • IP: <new IP>
  • Server: <new server name>
  • Alias (CNAME): Geodata

The change propagates across your environment after a bit, and ta-dah, stuff works just like it did when you sorted out the whole migration process in sandbox, dev, and test environments.

tim

AngelaVanderpas1
Emerging Contributor

This is very helpful.  What if you are upgrading sql without changing the machine / instance?

Can you do a sql back up restore after upgrading sql?

TimMinter
Frequent Contributor

I kind of failed to mention that the more recent SQL Server instance is on new hardware, didn't I?  So, yes, I would expect things to be even easier if you're upgrading in-place on your current hardware.  No AD Alias (CNAME) changes needed.

Check the SQL Server help for your version or with your DBA regarding when and how to backup when upgrading.  My experience has been good and easy with backup/restore, so nothing really to report.

tim

JakeSkinner
Esri Esteemed Contributor

@AngelaVanderpas1 all you would have to do is upgrade your SQL instance.  There would be nothing on the ArcGIS side of things required.

Rodrigo_DaSilva
Occasional Contributor

hey guys. @JakeSkinner  Could you provide the version with that fix you mentioned? For me it is interesting that only the reference to the database is redone. Out of curiosity, in the parameters, I used the host IP address of the database for testing.

previousInstance = '10.10.x.xx' # Previous SQL Server instance
newInstance = '172.29.x.xx' # New SQL Server Instance
previousDSID = 'd96f81ca-42e6-4380-935d-a2082b910031' # Previous SQL Server Instance DSID
newDSID = 'b579344a-db7f-4e26-802f-0fa5f1eb0614' 
FabioNeiraAlzate
Occasional Contributor

Can this be adapted to other database engines such as Oracle or Postgresql?

MarceloMarques
Esri Regular Contributor

ArcGIS Pro 3.2 allows you to change the data source of the ArcGIS Server services without the need to republish.  But this can still be a hurdle if you have a large number of services. Therefore the best practice is to create a DNS alias and use that alias in the geodatabase connection files to publish the services.

Example: 

GIS-PROD-DB-1  DNS alias resolves to the database server hostname  GIS-SRV-DB-1

the geodatabases migrate from host GIS-SRV-DB-1 to GIS-SRV-DB-2

then just need to change GIS-PROD-DB-1 to resolve to GIS-SRV-DB-2

This will work fine for Oracle Easy Connect, SQL Server and PostgreSQL.

If you are using Oracle then instead of a DNS alias you can use Oracle TNSNAMES.ora that allows the same flexibility, talk to your Oracle Database Administrator to setup TNSNAMES.ora.

JakeSkinner
Esri Esteemed Contributor

@MarceloMarques this is interesting, what is the workflow to change an ArcGIS Server service data source using Pro 3.2?

MarceloMarques
Esri Regular Contributor
AbiDhakal
Frequent Contributor

@JakeSkinnerthank goodness for you all good folks!

I'm in a similar situation, and so, I'm trying to prepare myself for the moment.

After reading your post, this is what I understand:

1. Backup of GIS Server (is this with WEBGISDR?)
2. Restore geodatabase to the new SQL Server instance
3. Register the geodatabase from the new SQL Server 2022 instance as a Data Store.
4. Update the 7 variables.
5. Stop GIS Server service.
6. Run the script
7. Start the GIS Service.

DONE!

Is there anything else I need to know?

Thank you,
Abi

JakeSkinner
Esri Esteemed Contributor

@AbiDhakal,

That should be it.  If possible, create snapshots of your servers after the WebGISDR is restored.  If there is an error, you can easily roll back.  Also, if for some reason the script continues to fail, you can update your existing data store connections with the new .sde connection file.  The only caveat of this is that the old SQL instance will still show in Server Manager when looking at the workspace info.

AbiDhakal
Frequent Contributor

@JakeSkinner 

Thank you for the message.

Why do I need to do a WebGISDR back-up of the entire ArcGIS Enterprise? I'm not trying to replace the ArcGIS Server machine. I'm only trying to replace the old 2016 SQL Server instance with a new 2022 SQL Server instance, and want to make sure that the services created from the old 2016 SQL Server instance do not have to be overwritten just because I have a new 2022 SQL Server instance.

We do take snapshots of our GIS Server everyday.

Thank you,
Abi

JakeSkinner
Esri Esteemed Contributor

@AbiDhakal that was my mistake, you do not need to create a WebGISDR backup.  If you have snapshots of the server, you'll be good.

AbiDhakal
Frequent Contributor

@JakeSkinner 

Thank you.

Will what you said earlier still apply in my case? "The only caveat of this is that the old SQL instance will still show in Server Manager when looking at the workspace info".

I appreciate you helping me with this.
Abi

 

JakeSkinner
Esri Esteemed Contributor

@AbiDhakal that only applies if you update the existing Database Data Store connection with a new SDE connection file that is pointing to the new SQL instance.

AbiDhakal
Frequent Contributor

@JakeSkinner 

I'm sorry I didn't understand that. So, if i were to have a completely new SQL Server instance with all the data inside new is when that applies?

Thank you. My apology for my ignorance.
Abi

JakeSkinner
Esri Esteemed Contributor

@AbiDhakal try the steps outlined in this document first.  If for some reason it does not work, restore your snapshot.  You can then update the existing data store connection with a SDE connection file pointing to the new SQL instance:

JakeSkinner_0-1702043357088.png

Your services will redirect to this new SQL instance at this point.  However, updating the existing data store connection will not update the workspace information when you click on this option for the service.  Though, it is in fact pointing to the new SQL instance.

 
 

workspace.jpg

 

AbiDhakal
Frequent Contributor

@JakeSkinner 

Ok. I think I got you.

In my case, however I do not think I will have to restore with a snapshot. I just got to find a way to connect with the new SQL Server instance.

I appreciate you. Thank you so very much.
Abi

Samuel_McAuley
Occasional Contributor

Hi @JakeSkinner this is a really great guide, thanks for putting it together! I am currently testing one or two variations of this, specifically looking at updating the source database on the same SQL Server instance. All I did was use your existing script and add an additional part during the manifest update, like so:

 

if re.search(previousInstance, data, re.IGNORECASE) or re.search(previousDB, data, re.IGNORECASE):
print(f"\nUpdating {service} manifest.json with new instance/db info")
data = re.sub(rf'\b{previousInstance}\b', newInstance, re.sub(rf'\b{previousDB}\b', newDB, data, flags=re.IGNORECASE), flags=re.IGNORECASE)

 

 

I can see that the service manifest has indeed updated for that service and the workspace information in Server Manager is updated, yet the service itself, when I open the feature layer in Pro, is still showing the dataset from the old DB. Have you had a similar problem previously? Do you know where else I need to perform these updates? Thanks in advance!

 

Edit: One additional question, would this be the same workflow if one was to migrate database instances and underlying RDBMS? Say I was shifting from one instance running Sql Server to a new instance with Postgres.

MiriEshel1
Emerging Contributor

Hello @JakeSkinner ,

I agree that this is a great guide. 

It looks like the script works for services in Enterprise environment.

We have an environment with stand alone ArcGIS Server (it is a bit different, e.g, There is no map directory within the service directory).

We also need to change the whole connection string from SQL Server to Postgres.

How difficult is changing this script? Do we have to look in all files that have to be changed? DO you have, by any chance, a similar script for stand alone ArcGIS Server?

Thanks a lot,

Miri

 

JakeSkinner
Esri Esteemed Contributor

@Samuel_McAuley @MiriEshel1 I have not tested this changing database types (i.e. SQL Server --> PostgreSQL) so I cannot guarantee this will work at the moment.

@Samuel_McAuley when you are attempting to change the database, does each database have the same users and permissions/privileges as the other?

Samuel_McAuley
Occasional Contributor

@JakeSkinner thanks for clarifying re changing of DB types - worth testing by the sounds! We are slated to be doing this move later this year so hopefully I will get a chance to test this soon.

To your second question, I have inspected the users and permissions through SQL Server Management Studio and they do not have identical users. Is this likely to be an issue in this example? They almost have the same users, just one of the databases has two additional users, otherwise they are identical in this respect. Interestingly the permissions are set up a bit differently from one to the next too. I would be interested to hear your thoughts on this.

MartinF
Emerging Contributor

Hi @JakeSkinner , hi @MarceloMarques 

we have a customer migrating from 10.9.1 to 11.3 with SQL Server.
Because of the data model change (no more database name in the egdb metadata, such as sde_table_registry), the services must also be overwritten so that the referenced services work.
Is that correct?
Do you also have an automation for this (Python)?

Best regards,
Martin

TimMinter
Frequent Contributor

Hi @MartinF - anecdotally, I just upgraded the EGDB schema in a SQL Server 2019 db from 10.9.1.*** to 11.3 on Monday in a development environment after a good db backup.  ArcGIS Server map/feature/editing services that depend on the EGDB objects worked just fine without any changes.  ArcGIS Pro Layer files have the db name prefix part of the EGDB schema hardcoded, but ArcGIS Pro sorted it out without any changes to the layer files.  ModelBuilder models ran fine without changes.  I found some Python code that was doing some string manipulation on the fully expressed object name (e.g. <db>.<schema>.<object> that I expect to fail when I test it soon.  Code that depends on the db objects outside of the ArcGIS sphere continues to work because the db name element in the fully expressed object name is really just a value in one or more of the EGDB sde management tables, so it's not returned when you're working with the objects in SSMS.  All pretty much good to go without any major fixes.

Cheers and good luck,

tim

MartinF
Emerging Contributor

Hello @TimMinter,

great, thanks a lot for the quick information (... and for testing it!!!)
👍

Regards
Martin

 

LouisDECOMBE
Frequent Contributor

Hi @JakeSkinner 

Thank you for your excellent work. It's been very helpful in understanding what needs to be done.

In my case, I have many databases registered in ArcGIS Server, and I don't really want to create a new one for the new instance. I plan to simply update them using the SDE file. However, from what I understand, while the map services will continue to function, the information displayed in each map service will reflect the old data. This isn't too bad, right?

That being said, is there a method or script available that allows me to update the information in each map service after updating the database (without creating a new one), ensuring that the IDs remain unchanged?

Thank you for your advice.

2024-08-19_11h26_30.png

2024-08-19_11h29_10.png

JakeSkinner
Esri Esteemed Contributor

@LouisDECOMBE for the script variables, you can update the previousInstance and newInstance.  For the newDSID variable, simply specify this to the be the same as the previousDSID variable.

JakeSkinner_0-1724066295983.png

 

LouisDECOMBE
Frequent Contributor

@JakeSkinner , Ah yes, I hadn’t even thought of that! Thank you. I will test it

 
 
LouisDECOMBE
Frequent Contributor

@JakeSkinner

I tried, but it seems there was no change in the manifest or MSD file, even though AGS was stopped.

 

2024-08-19_15h10_22.png

I have the new manifest in the scratch folder, but the information inside is the same as before.

2024-08-19_15h17_57.png

Any ideas?

JakeSkinner
Esri Esteemed Contributor

@LouisDECOMBE I'm not sure which release, but it looks like the MSD files, when extracted, now contain a directory called layers instead of map.  I've updated the script to accommodate for this.  Try the latest script and let me know if this resolves the issue.

LouisDECOMBE
Frequent Contributor

@JakeSkinner ,

Thank you. I think I see where my problem is.

In the image below, the red boxes indicate what the script manages to update. The instance name is different from the SQL server name (blue box). Thus, the script only updates the parts outlined in red. Maybe I need to adapt it to also update the parts in blue. If you have any ideas, I’m all ears.

Additionally, the files in the config-store directory are properly updated. However, in the arcgisinput folder, only the p20/name_service.msd files are updated, not the manifest files. Could this be an issue?

In any case, thank you for your prompt response each time.

Have a great day!

 

data_store_explication.png

JakeSkinner
Esri Esteemed Contributor

@LouisDECOMBE I'm having trouble reproducing this with the latest script.  Are you seeing the similar print statements in your IDE console when you execute the script:

JakeSkinner_0-1724173723912.png

 

MattiasEkström
Frequent Contributor

We are about to migrate our SQL Server 2016 to 2022 on a new server, so this thread is very helpful.
It's aldready been discussed in this thread but just to be clear, if I just update my existing datasource with a new .sde file, will everything work except the service workspace dialog shows old values? I can live with that and it seems like an easier option, or is there any other drawback?

@TimMintermentioned another approach with aliases for the SQL Server machines, our IT depaterment said that we should use an alias for the new server. But if we set that alias for the old/existing server I would have to update all my current connections to the database to use the alias instead of the server name right? Then I might as well wait until the new server is up and update the data source to the new server and use the alias, but it will be easier next time?

JakeSkinner
Esri Esteemed Contributor

@MattiasEkström 

It's aldready been discussed in this thread but just to be clear, if I just update my existing datasource with a new .sde file, will everything work except the service workspace dialog shows old values?

Yes, that is the easiest option.  You can then execute the script afterwards to update the workspace connection info.  Simply use the same value for the previousDSID and newDSID variables in the script.

But if we set that alias for the old/existing server I would have to update all my current connections to the database to use the alias instead of the server name right?

Yes, that is also correct.

MattiasEkström
Frequent Contributor

Thanks @JakeSkinner !

I have several databases in the same instance, some of them belong to other systems where I read data through query layers. I have one data store for each database. As I understand it, I need to run the script once for each database/data store? and if I move one database at a time, instance names should not be changed in the wrong places but only in files that belong to the map services affected by the current data store (DSID)?

JakeSkinner
Esri Esteemed Contributor

@MattiasEkström actually, I just got off the phone with a customer where we executed this script.  They had several Data Store connections to different databases, and all on the same SQL instance.  They updated them all using a new SDE connection file. 

We only had to run the script once since there was only one instance.  The script will still update the service instance even though the previousDSID was not found.  

 

ShelbyZelonisRoberson
Frequent Contributor

@JakeSkinner 

We are about to migrate my enterprise geodatabases to a new machine with a new IP address. I have a ton of registered services published to my Portal.

I've had two separate calls with Esri Tech Support this week and was told that it is impossible to change the instance name or IP address without breaking all of the services and having to republish them. Am I right that this post means that is NOT the case? I can run this script and avoid having to recreate everything? I'm extra confused now! 

Where do you run this script; on the ArcGIS Server machine? 

Version history
Last update:
‎08-19-2024 04:54 PM
Updated by:
Contributors