Select to view content in your preferred language

Automating Release Process for Experience Builder App

164
3
2 weeks ago
Labels (2)
fdeters
New Contributor II

How can I automate the Dev>Production promotion process for a map-centric Experience Builder app where the Production version uses different data from the Dev version?

---

Using Python API 2.3.0, AGOL Map Viewer, and AGOL Experience Builder (not Developer Edition)

---

I'm building an Experience Builder app that will be used to view and edit a high-value dataset for my organization. We have an ecosystem in AGOL that includes both Dev and Prod versions of the data. There are multiple views and related tables of the dataset, so there are several items used in the app that have both Dev and Prod versions in our organization.

My strategy so far is to have two versions (Dev and Prod) of both the EB app and the Web Map that it consumes. I make updates in the Dev map and app, then use ArcGIS Assistant to

  1. Literally copy the JSON from the Dev versions to the Prod versions ("Data" for the web map; and "Data", "config/config.json", and any other files such as images for the EB app)
  2. Update the `url` and `itemId` of the data resources (such as operationalLayers or tables) to the Prod values in the Prod version of the app.

This ArcGIS Assistant process has worked surprisingly well. I especially like that it doesn't entail creating a new Production item every time (I don't want the EB app URL to change).

However, as the app will soon have more environment-specific data sources, I'm looking for a way to automate the process, probably using the Python API. I've spent some time trying already, but haven't found a way to do it yet. In particular, I tried

  • The `arcgis.gis.Item.update()` method on an Item representing the Web Map, trying to replace the JSON data on the Prod map with the data from the Dev map. I got this error: "ValueError: The `update` method requires a user to pass a `fileName` value in the `item_properties` if the file name is not defined on the Item"
  • The `arcgis.mapping.WebMap.update_layer()` method. Well, I didn't actual try this, but the documentation explicitly says that changing the `itemId` of a Feature Layer using that method will not work.

Does anyone have any suggestions on how to make this work using the Python API, or even a REST API? Or any other automation method, really.

0 Kudos
3 Replies
EarlMedina
Esri Regular Contributor

Can you elaborate on your attempt using the arcgis.gis.Item.update() method ? How were you passing in the JSON? Were you reading from a file?

0 Kudos
fdeters
New Contributor II

@EarlMedina Sure, here's the gist of my attempt:

agol = GIS(username=USER, password=PASS)
qa_map_item = agol.content.get(QA_MAP_ID)
prod_map_item = agol.content.get(PROD_MAP_ID)

qa_map_data = io.StringIO(json.dumps(qa_map_item.get_data()))
prod_map_item.update(item_properties={}, data=qa_map_data)

 And that last line is where I get the `fileName` error

0 Kudos
EarlMedina
Esri Regular Contributor

Ah, for map to map this is a simple fix:

 

import json
from arcgis import GIS

gis = GIS("https://www.arcgis.com", "user", "pass")

map_a_id = "iusdhjfuihjsdiojmg23423432klkklj"
map_b_id = "opo9o0pokszxcvbnmopjkwer87923459"

map_a = gis.content.get(map_a_id)
map_b = gis.content.get(map_b_id)

data = map_a.get_data()
item_properties = {"text": json.dumps(data)}
map_b.update(item_properties)