ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Publishing a map service with Python

You can automate map service publishing in a Python script. To do this, you need to call the following sequence of functions from the arcpy.mapping module and tools from the Server toolbox.

  1. Use the arcpy.mapping function CreateMapSDDraft to create a draft service definition (.sddraft). This function reads your map document (MXD) and creates the draft service definition.

    Tip:

    The above-linked topic contains a full code example for publishing a map service using Python.

  2. Use the arcpy.mapping function AnalyzeForSD to analyze your draft service definition for errors that might prevent its publishing. This function returns a Python list of errors, warnings, and informational messages that can help you validate whether your map is ready for publishing. This list is similar to what you get when you click the Analyze button from the Service Editor dialog box in ArcGIS Desktop.
  3. Run the Stage Service geoprocessing tool on your draft service definition. This converts your draft into a service definition (.sd) that is ready to publish to ArcGIS Server.
  4. Run the Upload Service Definition geoprocessing tool to publish your service definition as a service.

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal