-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[App Service] Fix #18697: az webapp config ssl create: Add --wait flag for managed certificate automation
#33068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -521,6 +521,9 @@ def load_arguments(self, _): | |||||
| c.argument('hostname', help='The custom domain name') | ||||||
| c.argument('name', options_list=['--name', '-n'], help='Name of the web app.') | ||||||
| c.argument('resource-group', options_list=['--resource-group', '-g'], help='Name of resource group.') | ||||||
| c.argument('wait', options_list=['--wait'], action='store_true', default=False, | ||||||
| help='Wait up to 10 minutes for the certificate to be created. ' | ||||||
| 'Returns an error if creation times out instead of silently returning.') | ||||||
|
||||||
| 'Returns an error if creation times out instead of silently returning.') | |
| 'Returns an error if creation times out instead of silently returning None (no result).') |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5960,7 +5960,7 @@ def import_ssl_cert(cmd, resource_group_name, key_vault, key_vault_certificate_n | |||||||||||||||||||||||||||||||||||||
| certificate_envelope=kv_cert_def) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def create_managed_ssl_cert(cmd, resource_group_name, name, hostname, slot=None, certificate_name=None): | ||||||||||||||||||||||||||||||||||||||
| def create_managed_ssl_cert(cmd, resource_group_name, name, hostname, slot=None, certificate_name=None, wait=False): | ||||||||||||||||||||||||||||||||||||||
| Certificate = cmd.get_models('Certificate') | ||||||||||||||||||||||||||||||||||||||
| hostname = hostname.lower() | ||||||||||||||||||||||||||||||||||||||
| client = web_client_factory(cmd.cli_ctx) | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -5997,7 +5997,8 @@ def create_managed_ssl_cert(cmd, resource_group_name, name, hostname, slot=None, | |||||||||||||||||||||||||||||||||||||
| poll_url = ex.response.headers['Location'] if 'Location' in ex.response.headers else None | ||||||||||||||||||||||||||||||||||||||
| if ex.response.status_code == 202 and poll_url: | ||||||||||||||||||||||||||||||||||||||
| r = send_raw_request(cmd.cli_ctx, method='get', url=poll_url) | ||||||||||||||||||||||||||||||||||||||
| poll_timeout = time.time() + 60 * 2 # 2 minute timeout | ||||||||||||||||||||||||||||||||||||||
| poll_timeout_minutes = 10 if wait else 2 | ||||||||||||||||||||||||||||||||||||||
| poll_timeout = time.time() + 60 * poll_timeout_minutes | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| while r.status_code != 200 and time.time() < poll_timeout: | ||||||||||||||||||||||||||||||||||||||
| time.sleep(5) | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -6008,6 +6009,11 @@ def create_managed_ssl_cert(cmd, resource_group_name, name, hostname, slot=None, | |||||||||||||||||||||||||||||||||||||
| return r.json() | ||||||||||||||||||||||||||||||||||||||
| except ValueError: | ||||||||||||||||||||||||||||||||||||||
| return r.text | ||||||||||||||||||||||||||||||||||||||
| if wait: | ||||||||||||||||||||||||||||||||||||||
| raise CLIError("Managed Certificate creation for '{}' timed out after {} minutes. " | ||||||||||||||||||||||||||||||||||||||
| "Check status with 'az webapp config ssl show -g {} " | ||||||||||||||||||||||||||||||||||||||
| "--certificate-name {}'.".format(hostname, poll_timeout_minutes, | ||||||||||||||||||||||||||||||||||||||
| resource_group_name, certificate_name)) | ||||||||||||||||||||||||||||||||||||||
| logger.warning("Managed Certificate creation in progress. Please use the command " | ||||||||||||||||||||||||||||||||||||||
| "'az webapp config ssl show -g %s --certificate-name %s' " | ||||||||||||||||||||||||||||||||||||||
| " to view your certificate once it is created", resource_group_name, certificate_name) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+6012
to
6019
|
||||||||||||||||||||||||||||||||||||||
| if wait: | |
| raise CLIError("Managed Certificate creation for '{}' timed out after {} minutes. " | |
| "Check status with 'az webapp config ssl show -g {} " | |
| "--certificate-name {}'.".format(hostname, poll_timeout_minutes, | |
| resource_group_name, certificate_name)) | |
| logger.warning("Managed Certificate creation in progress. Please use the command " | |
| "'az webapp config ssl show -g %s --certificate-name %s' " | |
| " to view your certificate once it is created", resource_group_name, certificate_name) | |
| app_type = 'functionapp' if is_functionapp(cmd, resource_group_name, name) else 'webapp' | |
| if wait: | |
| raise CLIError("Managed Certificate creation for '{}' timed out after {} minutes. " | |
| "Check status with 'az {} config ssl show -g {} " | |
| "--certificate-name {}'.".format(hostname, poll_timeout_minutes, | |
| app_type, resource_group_name, certificate_name)) | |
| logger.warning("Managed Certificate creation in progress. Please use the command " | |
| "'az %s config ssl show -g %s --certificate-name %s' " | |
| " to view your certificate once it is created", app_type, resource_group_name, | |
| certificate_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitis being added inside thefor scope in ['webapp', 'functionapp']loop, so--waitwill also become available onaz functionapp config ssl create(and will map intocreate_managed_ssl_cert). If this PR is intended to be webapp-only, scope this argument towebappinstead; if it’s intended to support functionapps too, please update functionapp help/examples (and ideally add coverage) to reflect the new flag.