If you run this code it will lock you out of your Enterprise account for 15 minutes.
import arcpy
try:
result = arcpy.server.StageService("Roads.sddraft", "Roads_hosted.sd")
except Exception as e:
print(e)
The output will look like this.
ERROR 001272: Analyzer errors were encountered ([{"code":"00102","message":"Map does not contain a required layer type for Map Service","object":"Roads"}]).
Failed to execute (StageService).
The error message is wrong. The map is fine. But at this point if you try to connect to your Portal you get something like this,
from arcgis.gis import GIS
try:
gis = GIS("https://delta.co.clatsop.or.us/portal", profile='brian')
except Exception as e:
print(e)
Unable to generate token.
Too many invalid logins. Please try again later.
(Error Code: 400)
You will not be able to access your Enterprise server from either Pro or a web browser (or your Python scripts) for 15 minutes. (Need I say that the credentials are perfect? That is not relevant.)
I hear you ask "what is in that sddraft file that is so dangerous? I want one too!"
Ha! That could be a closely held secret, that I would be reluctant to share, but you deserve breaks too! I mean think of it. I had to test, wait 15 minute, test, wait,... until I hit the correct random meaningless unrelated line of code. (Yes-- I put in a support ticket asking how to clear the 15 timer or REMOVE it but have not heard back yet.)
Okay, my secret! In setting up the sddraft, I set the wrong value for the property "federatedServerUrl" I gave it a reference to an AGS connection file instead of the Url. I'd think this would result in an HTTP GET error, wouldn't you?
But it completely blew me out of the water (in 15 minute increments) even though the "StageService" method is just supposed to test your SDdraft for mistakes and then repackage it into an SD file ready for upload.
There you go! Your ticket to lots of breaks!! Enjoy!