Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5c144ac
add AZ support
StrawnSC May 16, 2022
340e37d
Merge pull request #105 from StrawnSC/az-aca
StrawnSC May 16, 2022
a637114
bump version, add history, fix style
StrawnSC May 16, 2022
5d85708
auto-register Microsoft.App RP
StrawnSC May 16, 2022
f51df48
autoregister on containerapp and env create
StrawnSC May 16, 2022
a51745a
Finished auth microsoft.
May 18, 2022
dac8c2f
Added prototypes of other identity providers.
May 18, 2022
522e6dd
Added param help.
May 18, 2022
9be335b
Added error handling for no easy auth case.
May 18, 2022
0eca228
Adding cmds & tests for Container app certs & domains (#107)
lil131 May 19, 2022
8185b3f
Merge branch 'containerapp-0.3.5' into autoregister-msft.app
StrawnSC May 19, 2022
59369f7
Added auth update and show.
May 19, 2022
1185d69
Moved utils to utils. Removed CLIErrors from old code. Removed commen…
May 19, 2022
ea0283d
fixes for CI
StrawnSC May 19, 2022
9a85503
use capps RP constant
StrawnSC May 19, 2022
6f2943c
Merge pull request #106 from StrawnSC/autoregister-msft.app
StrawnSC May 19, 2022
430cee2
rerecord tests; add credscan suppressions
StrawnSC May 19, 2022
873e531
Fixed style issues. Fixed sdk version.
May 19, 2022
5c87013
more CI fixes
StrawnSC May 19, 2022
8ad4ae0
Fixed merge conflicts.
May 19, 2022
11aeb5e
Updated history. Changed constant values instead of using python meth…
May 19, 2022
873a15f
Added help text for subgroups with examples.
May 19, 2022
e7137ff
Updated util. Fixed style issues.
May 19, 2022
8d31890
Merge pull request #108 from haroonf/authconfig
StrawnSC May 19, 2022
433433a
Revert "Add auth subgroups" (#109)
runefa May 19, 2022
90bfb2a
use new microsoft.graph API
StrawnSC May 4, 2022
baf9342
wip
StrawnSC May 20, 2022
d4f6cec
remove unused function
StrawnSC May 20, 2022
054db9b
Removed AuthClient sdk.
May 20, 2022
bbc1842
Added back AuthConfig.
May 20, 2022
8d31f6a
Removed old references. Limited oidc provider secret name. Fixed warn…
May 20, 2022
de354e6
Fixed facebook show bug.
May 20, 2022
87099c6
adding hostname tests with ASD
lil131 May 20, 2022
8f31760
fix location & add more test cases
lil131 May 20, 2022
b7f37a1
minor changes
lil131 May 20, 2022
699d2fc
rm redundant whitespaces
lil131 May 20, 2022
2ba057f
mark custom domain test as live_only
lil131 May 20, 2022
e3b3a59
Fixed error handling.
May 20, 2022
cf297ae
rm yaml files
lil131 May 21, 2022
2d39def
Merge pull request #110 from StrawnSC/microsoft.graph
StrawnSC May 22, 2022
4739052
add breaking change history note
StrawnSC May 22, 2022
a6fb46d
Merge pull request #112 from lil131/location-fix
StrawnSC May 22, 2022
1e977dd
Merge branch 'containerapp-0.3.5' into authconfig
StrawnSC May 22, 2022
e5237b6
bug fix in 'az containerapp auth update'
StrawnSC May 22, 2022
4b9eaab
Merge pull request #111 from haroonf/authconfig
StrawnSC May 22, 2022
8124269
remove dependencies on core CLI role module functions
StrawnSC May 22, 2022
0ae7357
remove 'BREAKING CHANGE' from history entry
StrawnSC May 23, 2022
6c86217
resolve PR comments
StrawnSC May 23, 2022
b671136
add test recording and remove live_only
StrawnSC May 23, 2022
881dbd8
make live only test live_only again
StrawnSC May 23, 2022
59eb990
remove unnecessary option lists
StrawnSC May 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions scripts/ci/credscan/CredScanSuppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,17 @@
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_env_dapr_components.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_env_e2e.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_env_storage.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_identity_e2e.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_identity_system.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_identity_user.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_ingress_e2e.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_ingress_traffic_e2e.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_logstream.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_update.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_dapr_e2e.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_up_image_e2e.yaml"
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_up_image_e2e.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\recordings\\test_containerapp_custom_domains_e2e.yaml",
"src\\containerapp\\azext_containerapp\\tests\\latest\\cert.pfx",
"src\\containerapp\\azext_containerapp\\tests\\latest\\test_containerapp_commands.py",
"src\\containerapp\\azext_containerapp\\tests\\latest\test_containerapp_env_commands.py"
],
"_justification": "Dummy resources' keys left during testing Microsoft.App (required for log-analytics to create managedEnvironments)"
}
Expand Down
9 changes: 9 additions & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
Release History
===============

0.3.5
++++++
* Add parameter --zone-redundant to 'az containerapp env create'
* Added 'az containerapp env certificate' to manage certificates in a container app environment
* Added 'az containerapp hostname' to manage hostnames in a container app
* Added 'az containerapp ssl upload' to upload a certificate, add a hostname and the binding to a container app
* Added 'az containerapp auth' to manage AuthConfigs for a containerapp
* Require Azure CLI version of at least 2.37.0

0.3.4
++++++
* BREAKING CHANGE: 'az containerapp up' and 'az containerapp github-action add' now use the github repo's default branch instead of "main"
Expand Down
160 changes: 160 additions & 0 deletions src/containerapp/azext_containerapp/_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,22 @@ def get_auth_token(cls, cmd, resource_group_name, name):
r = send_raw_request(cmd.cli_ctx, "POST", request_url)
return r.json()

@classmethod
def validate_domain(cls, cmd, resource_group_name, name, hostname):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerApps/{}/listCustomHostNameAnalysis?api-version={}&customHostname={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
name,
STABLE_API_VERSION,
hostname)

r = send_raw_request(cmd.cli_ctx, "POST", request_url)
return r.json()
Comment on lines +420 to +432
Copy link
Contributor

@zhoxing-ms zhoxing-ms May 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these requests not considered to be implemented in the Python SDK method, but directly request the REST service?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhoxing-ms our plan with the az containerapp commands was to use raw requests while in the extension, and then use the SDK when we put this in a core CLI command module -- similar to the appservice-kube commands. This has helped us keep the extension install size down and add features independently of their support in the SDK. We were under the impression that using raw requests is not allowed in the core CLI but permissible in CLI extensions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhoxing-ms , @StrawnSC is right - the swagger & Python SDK changes were too delayed for us to take a dependency on this. POST GA we plan to move this to using SDK completely + maybe move to core-cli as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks~



class ManagedEnvironmentClient():
@classmethod
Expand Down Expand Up @@ -584,6 +600,94 @@ def list_by_resource_group(cls, cmd, resource_group_name, formatter=lambda x: x)

return env_list

@classmethod
def show_certificate(cls, cmd, resource_group_name, name, certificate_name):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
api_version = STABLE_API_VERSION
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/certificates/{}?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
name,
certificate_name,
api_version)

r = send_raw_request(cmd.cli_ctx, "GET", request_url, body=None)
return r.json()

@classmethod
def list_certificates(cls, cmd, resource_group_name, name, formatter=lambda x: x):
certs_list = []

management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
api_version = STABLE_API_VERSION
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/certificates?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
name,
api_version)

r = send_raw_request(cmd.cli_ctx, "GET", request_url, body=None)
j = r.json()
for cert in j["value"]:
formatted = formatter(cert)
certs_list.append(formatted)
return certs_list

@classmethod
def create_or_update_certificate(cls, cmd, resource_group_name, name, certificate_name, certificate):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
api_version = STABLE_API_VERSION
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/certificates/{}?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
name,
certificate_name,
api_version)

r = send_raw_request(cmd.cli_ctx, "PUT", request_url, body=json.dumps(certificate))
return r.json()

@classmethod
def delete_certificate(cls, cmd, resource_group_name, name, certificate_name):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
api_version = STABLE_API_VERSION
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/certificates/{}?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
name,
certificate_name,
api_version)

return send_raw_request(cmd.cli_ctx, "DELETE", request_url, body=None)

@classmethod
def check_name_availability(cls, cmd, resource_group_name, name, name_availability_request):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
api_version = STABLE_API_VERSION
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/checkNameAvailability?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
name,
api_version)

r = send_raw_request(cmd.cli_ctx, "POST", request_url, body=json.dumps(name_availability_request))
return r.json()


class GitHubActionClient():
@classmethod
Expand Down Expand Up @@ -900,3 +1004,59 @@ def list(cls, cmd, resource_group_name, env_name, formatter=lambda x: x):
env_list.append(formatted)

return env_list


class AuthClient():
@classmethod
def create_or_update(cls, cmd, resource_group_name, container_app_name, auth_config_name, auth_config_envelope, no_wait=False):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
api_version = STABLE_API_VERSION
sub_id = get_subscription_id(cmd.cli_ctx)
request_url = f"{management_hostname}subscriptions/{sub_id}/resourceGroups/{resource_group_name}/providers/Microsoft.App/containerApps/{container_app_name}/authConfigs/{auth_config_name}?api-version={api_version}"

if "properties" not in auth_config_envelope: # sdk does this for us
temp_env = auth_config_envelope
auth_config_envelope = {}
auth_config_envelope["properties"] = temp_env

r = send_raw_request(cmd.cli_ctx, "PUT", request_url, body=json.dumps(auth_config_envelope))

if no_wait:
return r.json()
elif r.status_code == 201:
request_url = f"{management_hostname}subscriptions/{sub_id}/resourceGroups/{resource_group_name}/providers/Microsoft.App/containerApps/{container_app_name}/authConfigs/{auth_config_name}?api-version={api_version}"
return poll(cmd, request_url, "waiting")

return r.json()

@classmethod
def delete(cls, cmd, resource_group_name, container_app_name, auth_config_name, no_wait=False):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
api_version = STABLE_API_VERSION
sub_id = get_subscription_id(cmd.cli_ctx)
request_url = f"{management_hostname}subscriptions/{sub_id}/resourceGroups/{resource_group_name}/providers/Microsoft.App/containerApps/{container_app_name}/authConfigs/{auth_config_name}?api-version={api_version}"

r = send_raw_request(cmd.cli_ctx, "DELETE", request_url)

if no_wait:
return # API doesn't return JSON (it returns no content)
elif r.status_code in [200, 201, 202, 204]:
request_url = f"{management_hostname}subscriptions/{sub_id}/resourceGroups/{resource_group_name}/providers/Microsoft.App/containerApps/{container_app_name}/authConfigs/{auth_config_name}?api-version={api_version}"
if r.status_code == 200: # 200 successful delete, 204 means storage not found
from azure.cli.core.azclierror import ResourceNotFoundError
try:
poll(cmd, request_url, "scheduledfordelete")
except ResourceNotFoundError:
pass
logger.warning('Containerapp AuthConfig successfully deleted')
return

@classmethod
def get(cls, cmd, resource_group_name, container_app_name, auth_config_name):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
api_version = STABLE_API_VERSION
sub_id = get_subscription_id(cmd.cli_ctx)
request_url = f"{management_hostname}subscriptions/{sub_id}/resourceGroups/{resource_group_name}/providers/Microsoft.App/containerApps/{container_app_name}/authConfigs/{auth_config_name}?api-version={api_version}"

r = send_raw_request(cmd.cli_ctx, "GET", request_url)
return r.json()
12 changes: 12 additions & 0 deletions src/containerapp/azext_containerapp/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,17 @@
LONG_POLLING_INTERVAL_SECS = 10

LOG_ANALYTICS_RP = "Microsoft.OperationalInsights"
CONTAINER_APPS_RP = "Microsoft.App"

MAX_ENV_PER_LOCATION = 2

MICROSOFT_SECRET_SETTING_NAME = "microsoft-provider-authentication-secret"
FACEBOOK_SECRET_SETTING_NAME = "facebook-provider-authentication-secret"
GITHUB_SECRET_SETTING_NAME = "github-provider-authentication-secret"
GOOGLE_SECRET_SETTING_NAME = "google-provider-authentication-secret"
MSA_SECRET_SETTING_NAME = "msa-provider-authentication-secret"
TWITTER_SECRET_SETTING_NAME = "twitter-provider-authentication-secret"
APPLE_SECRET_SETTING_NAME = "apple-provider-authentication-secret"
UNAUTHENTICATED_CLIENT_ACTION = ['RedirectToLoginPage', 'AllowAnonymous', 'RejectWith401', 'RejectWith404']
FORWARD_PROXY_CONVENTION = ['NoProxy', 'Standard', 'Custom']
CHECK_CERTIFICATE_NAME_AVAILABILITY_TYPE = "Microsoft.App/managedEnvironments/certificates"
Loading