Clean up Azure Function secrets (#179)

- Fixes Azure function not-starting up after re-deploying it 10 times

Co-authored-by: stas <statis@microsoft.com>
This commit is contained in:
Stas 2021-03-31 08:44:35 -07:00 коммит произвёл GitHub
Родитель 3c93514690
Коммит 408e17d015
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 32 добавлений и 0 удалений

Просмотреть файл

@ -362,6 +362,36 @@ class RaftServiceCLI():
return (f"TableEndpoint=https://{storage_account}"
f".table.core.windows.net/;SharedAccessSignature={sas_url}")
def cleanup_function_secret_snapshots(self, storage_account, function_name):
container_exists = az_json(
'storage container exists'
f' --account-name {storage_account}'
' --name "azure-webjobs-secrets"'
)
if container_exists['exists'] == True:
snapshots = az_json(
'storage blob list'
f' --account-name {storage_account}'
' --container-name "azure-webjobs-secrets"'
f' --prefix "{function_name}/host.snapshot"')
for snapshot in snapshots:
name = snapshot['name']
try:
az(
'storage blob delete'
f' --account-name {storage_account}'
f' --container-name {snapshot["container"]}'
f' --name "{name}"'
' --delete-snapshots include'
)
except RaftAzCliException as ex:
if ex.error_message.startswith("WARNING:"):
pass
else:
raise
def container_image_name(self, registry_image_name):
return (
f"{self.context['registry']}"
@ -1153,6 +1183,8 @@ class RaftServiceCLI():
container_registry_password,
tools_file_share)
self.cleanup_function_secret_snapshots(self.definitions.storage_utils, self.definitions.orchestrator)
self.upload_utils(tools_file_share)
if self.context.get('isDevelop') and not skip_sp_deployment: