Краткая информация
Создает файл подключения ArcGIS Server, который можно использовать для доступа к сайту ArcGIS Server.
Обсуждение
Если вы создаете соединение с ArcGIS Server и сайт ArcGIS Server интегрирован с развертыванием ArcGIS Enterprise, необходимо войти через портал ArcGIS Enterprise. Вы можете сделать это с помощью функции SignInToPortal. Для этих сайтов можно создать только соединение, использующее ресурсы сайта.
Если вы создаете соединение с ArcGIS Server и сайт ArcGIS Server является автономным развертыванием, по умолчанию создается подключение на уровне пользователя. Дополнительно вы можете запросить, чтобы файл подключения обеспечивал подключение с повышенными правами для возможности публикации сервисов. Этот запрос будет выполнен только в случае, если у подключенного пользователя есть достаточно прав для разрешения подключения с повышенными правами.
Доступно несколько вариантов для управления доступом к ресурсам сайта ArcGIS Server. Если сайт настроен на использование встроенного хранилища аутентификаций и анонимный доступ не разрешен, требуется имя пользователя и пароль. Создающему файл подключения следует учитывать его предполагаемое использование, чтобы правильно настроить хранение учетных данных и использование файла, как указано ниже:
- По умолчанию учетные данные не будут храниться постоянно в новом файле подключения, поскольку это наиболее безопасный вариант. Если учетные данные не сохраняются, скрипт, использующий файл, должен самостоятельно управлять входом на сайт ArcGIS Server, чтобы избежать появления диалогового окна входа при запуске скрипта. Скрипт может импортировать учетные данные из другого файла подключения ArcGIS Server с помощью функции ImportCredentials.
- Если файл будет использоваться скриптами, поддерживающими автоматизированные операции публикации, полезно хранить учетные данные в файле подключения, но следует проявить осторожность, чтобы обеспечить безопасность скрипта и файла, так как операции публикации требуют подключения с повышенными правами. Для публикации различных сервисов могут потребоваться разные учетные данные с повышенными правами.
- Если файл будет использоваться для доступа к сервисам и добавления их на карту, важно понимать, что система сопоставления сначала будет использовать уже установленное соединение с сайтом ArcGIS Server. Если соединение недоступно в памяти, для установления нового соединения система сопоставления будет использовать только учетные данные, хранящиеся в Диспетчере учетных данных Windows в профиле пользователя. Если учетные данные недоступны в Диспетчере учетных данных Windows, пользователь, открывший карту, должен выполнить вход.
После того как файл подключения ArcGIS Server будет создан с соответствующими правами, вы можете загрузить файл определения сервиса с помощью функции UploadServiceDefinition.
Синтаксис
CreateAGSServerConnection (ags_file_path, server_url, {username}, {password}, {save_credentials_to_wcm}, {save_credentials_to_file}, connection_type)| Параметр | Описание | Тип данных |
ags_file_path | The folder path where the output ArcGIS Server connection file (.ags) will be stored and the name of the file that will be created. The file extension must be .ags. | String |
server_url | The URL of the ArcGIS Server site. You mustspecify the server URL according to the site requirements. ArcGIS Pro only supports HTTPS connections to ArcGIS Server deployments. | String |
username | The username that will be used forArcGIS Server authentication if the ArcGIS Server site is a stand-alone deployment and has been configured to use a built-in identity store; a username is required in this configuration if anonymous access is not allowed. In all other configurations, provided credentials are ignored and will not be saved. When the ArcGIS Server site is federated with an ArcGIS Enterprise deployment, you must sign in using the ArcGIS Enterprise portal. | String |
password | The password that will be used forArcGIS Server authentication if the ArcGIS Server site is a stand-alone deployment and has been configured to use a built-in identity store; a password is required in this configuration if anonymous access is not allowed. In all other configurations, credentials are ignored and will not be saved. When the ArcGIS Server site is federated with an ArcGIS Enterprise deployment, you must sign in using the ArcGIS Enterprise portal. | String |
save_credentials_to_wcm | Specifies whether the username and password forArcGIS Server authentication will be stored in the Windows Credential Manager, which is part of the computer's operating system. The ArcGIS Pro mapping system only uses credentials stored in the Windows Credential Manager to sign in to the ArcGIS Server site, access its content, and draw data, because this storage mechanism is secure. If an operation is performed or a script is run on a different machine using the same connection file, the required credentials may not be available because a sign in has not yet occurred on that computer. A sign-in dialog box may appear.
(Значение по умолчанию — False) | Boolean |
save_credentials_to_file | Specifies whether the username and password forArcGIS Server authentication will be stored in the ArcGIS Server connection file (.ags). Python scripts can use the SignInToPortal function to access a federated server's content. For a stand-aloneArcGIS Server site, a script run on a Linux machine will not have access to the Windows Credential Manager to sign in and access the site's content. Use an encrypted login in your script; this option is more secure. Credentials can also be stored in the connection file; this option is less secure.
(Значение по умолчанию — False) | Boolean |
connection_type | Specifies the connection type that will be created to use or publish content on an ArcGIS Server site. When the ArcGIS Server site is federated with an ArcGIS Enterprise deployment, you can only create a connection to use the site's content. When the ArcGIS Server site is a stand-alone deployment, and you have sufficient privileges, the connection is created with the requested elevated connection type.
(Значение по умолчанию — USE_ SERVICES) | String |
| Тип данных | Описание |
| String | Полный путь к файлу подключения ArcGIS Server. |
Пример кода
Создайте файл подключения ArcGIS Server для анонимного доступа к сервисам с любого сайта ArcGIS Server. Сайт может быть либо интегрирован с порталом ArcGIS Enterprise, либо являться автономным развертыванием.
import arcpy
agsFileName = arcpy.CreateAGSServerConnection(
r"C:\Project\MyOrganization.ags",
"https://organization.example.com/server")Создайте файл подключения ArcGIS Server, который можно использовать для публикации сервисов в автономном развертывании ArcGIS Server.
import arcpy
12345678901234567890123456789012345678901234567890123456789012345678901234567890
agsFileName = arcpy.CreateAGSServerConnection(
r"C:\Project\MyServer.ags",
"https://organization.example.com/arcgis",
"MyUserName",
"MyPassword",
False,
True,
"PUBLISH_SERVICES")