Last active
August 30, 2019 02:28
-
-
Save andreas-wilm/62e23ad3fd45c3aeeace6a83c510e191 to your computer and use it in GitHub Desktop.
Convert Github JSON URL to directly usable "Deploy on Azure" link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse | |
TEMPLATEURL = "https://portal.azure.com/#create/Microsoft.Template/uri/" | |
def toraw(ghurl): | |
# convert github url to its raw equivalent, if needed | |
ghbase = "https://github.com" | |
ghrawbase = "https://raw.githubusercontent.com" | |
if ghbase in ghurl and "/blob/" in ghurl: | |
return ghurl.replace(ghbase, ghrawbase).replace("/blob/", "/") | |
else: | |
return ghurl | |
# example input json | |
json = "https://github.com/Azure/DataScienceVM/blob/master/Scripts/CreateDSVM/Ubuntu/dsvm-vmss-lowpri.json" | |
print(TEMPLATEURL.rstrip("/") + "/" + urllib.parse.quote(toraw(json), safe='')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment