Last active
March 23, 2022 18:50
-
-
Save JamesOsborn-SE/7ef45e707e7d81a7a639fb9a4e1f747a to your computer and use it in GitHub Desktop.
Azure Advanced Config to Local appsettings.json
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 json | |
def empty_lines_input(prompt='> ', n_lines=2): | |
'An `input` with `n_lines` empty line ending.' | |
all_input_strings = '' | |
# prompt the user for input | |
given_input = input(prompt) | |
all_input_strings += given_input | |
# and handle the two newline ending | |
while n_lines>0: | |
# if previous input is not empty prompt again | |
given_input = input('') | |
all_input_strings += '\n' + given_input | |
# check if it was an empty line | |
if not given_input: | |
n_lines -= 1 | |
else: | |
n_lines = 2 | |
return all_input_strings | |
contents = empty_lines_input('paste azure json config and hit return 3x when done: ') | |
serializedContents = json.loads(contents) | |
kvp = dict() | |
for item in serializedContents: | |
kvp[item['name']] = item['value'] | |
print("Appsettings: ") | |
print("==========================================================") | |
print(json.dumps(kvp, indent=1, separators=(',', ': '))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment