Publish_parameters aren't used when publishing .sd-files

415
0
01-09-2020 03:44 AM
AnttiKajanus
New Contributor III

It look like publishing feature service from a .sd-file doesn't take into account publish_parameters provided as a parameter. If I use geodatabase instead, it seems to work as expected. I assume that this is a bug in the API but does someone know if there is workaround with .sd files?  The idea behind the script is that we would like to publish different versions (ie. -dev, -qa) of the service as part of our DevOps pipeline from the same service. Geodatabases seems to work but it doesn't support symbology out of the box.

My test workflow here is very simple:

  • upload .sd file
  • publish with "GeoChatTest" and custom "Description"
  • publish with "GeoChatTest2" and custom "Description"

from arcgis.gis import GIS
import getpass

password = getpass.getpass("Enter password: ")

gis = GIS('organization', 'username', password)
print("Connected to: {}\nConnected as: {}".format(
                                                 gis.properties.urlKey + "." + gis.properties.customBaseUrl,
                                                 gis.users.me.username))

folder_name = 'GeoChatTest'
folder = gis.content.create_folder(folder=folder_name)
folder

uploaded_service_definition_item = gis.content.add(
   item_properties={
        'title' : 'GeoChat-ServiceDefinition',
        'snippet' : 'Test service definition',
        'description' : 'Test service that is created by using automation.',
        'accessInformation' : '',
        'licenseInfo' : 'For testing purposes only!', 
        'type' : 'Service Definition',
        'tags' : ['chat','geochat'],
        },
        folder =  folder_name,
        thumbnail=r"./data/publishing_data/thumbnail_geochat.png",
        data=r"./data/publishing_data/GeoChat.sd")
uploaded_service_definition_item

item_properties = {
        'name' : 'GeoChatTest',
        'description' : 'Test 1'
}

published_feature_service_item = uploaded_service_definition_item.publish(item_properties)
published_feature_service_item

item_properties = {
        'name' : 'GeoChatTest2',
        'description' : 'Test 2'
}

published_feature_service_item = uploaded_service_definition_item.publish(item_properties)
published_feature_service_item‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

What actually happens:

  • .sd file is uploaded
  • Feature Service is created with the name from the .sd file with description from the .sd file as well
  • Error on publish: RuntimeError: Service name 'GeoChat' already exists for 'ut5Ig3pyAO7DhCxU'

Atma ManiAndrew Chapkowski‌ thoughts?

0 Kudos
0 Replies