Skip to content
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

[App Service] Add support for linux sitecontainers #30776

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
124 changes: 124 additions & 0 deletions src/azure-cli/azure/cli/command_modules/appservice/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,9 @@
- name: Create a web app with a NodeJS 10.14 runtime and deployed from a local git repository.
text: >
az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName --runtime "node:12LTS" --deployment-local-git
- name: Create a web app which supports sitecontainers.
text: >
az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName --sitecontainers-app
- name: Create a web app with an image from DockerHub.
text: >
az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName -i nginx
Expand Down Expand Up @@ -2207,6 +2210,127 @@
crafted: true
"""

helps['webapp sitecontainers create'] = """
type: command
short-summary: Create sitecontainers for a linux webapp
long-summary: |
Multiple sitecontainers can be added at once by passing arg --sitecontainer-spec-file, which is the path to a json file containing an array of sitecontainer specs.
Example json file:
sarsharma marked this conversation as resolved.
Show resolved Hide resolved
[
{
"name": "firstcontainer",
"properties": {
"image": "myregistry.io/firstimage:latest",
"targetPort": "80",
"isMain": true,
"environmentVariables": [
{
"name": "VARIABLE_1",
"value": "APPSETTING_KEY1"
}
],
"volumeMounts": [
{
"containerMountPath": "mountPath",
"readOnly": true,
"volumeSubPath": "subPath"
}
]
}
},
{
"name": "secondcontainer",
"properties": {
"image": "myregistry.io/secondimage:latest",
"targetPort": "3000",
"isMain": false,
"authType": "SystemIdentity",
"startUpCommand": "MyStartupCmd"
}
},
{
"name": "thirdcontainer",
"properties": {
"image": "myregistry.io/thirdimage:latest",
"targetPort": "3001",
"isMain": false,
"authType": "UserAssigned",
"userManagedIdentityClientId": "ClientID"
}
},
{
"name": "fourthcontainer",
"properties": {
"image": "myregistry.io/fourthimage:latest",
"targetPort": "3002",
"isMain": false,
"authType": "UserCredentials",
"userName": "Username",
"passwordSecret": "Password"
}
}
]
examples:
- name: Create a sitecontainer for a linux webapp
text: az webapp sitecontainers create --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer --image MyImageRegistry.io/MyImage:latest --target-port 80 --is-main
- name : Create multiple sitecontainers for a linux webapp using a json sitecontainer-spec file
text: az webapp sitecontainers create --name MyWebApp --resource-group MyResourceGroup --sitecontainer-spec-file ./sitecontainersspec.json
"""


helps['webapp sitecontainers update'] = """
type: command
short-summary: Update a sitecontainer for a linux webapp
examples:
- name: Update a sitecontainer for a linux webapp
text: az webapp sitecontainers update --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer --image MyImageRegistry.io/MyImage:latest --target-port 3000 --is-main false
"""


helps['webapp sitecontainers delete'] = """
type: command
short-summary: Delete a sitecontainer for a linux webapp
examples:
- name: Delete a sitecontainer for a linux webapp
text: az webapp sitecontainers delete --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer
"""


helps['webapp sitecontainers show'] = """
type: command
short-summary: List the details of a sitecontainer for a linux webapp
examples:
- name: List the details of a sitecontainer for a linux webapp
text: az webapp sitecontainers show --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer
"""


helps['webapp sitecontainers list'] = """
type: command
short-summary: List all the sitecontainers for a linux webapp
examples:
- name: List all the sitecontainers for a linux webapp
text: az webapp sitecontainers list --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer
"""


helps['webapp sitecontainers status'] = """
type: command
short-summary: Get the status of a sitecontainer for a linux webapp
examples:
- name: Get the status of a sitecontainer for a linux webapp
text: az webapp sitecontainers status --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer
"""

helps['webapp sitecontainers log'] = """
type: command
short-summary: Get the logs of a sitecontainer for a linux webapp
examples:
- name: Get the logs of a sitecontainer for a linux webapp
text: az webapp sitecontainers log --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer
"""


helps['webapp up'] = """
type: command
short-summary: >
Expand Down
31 changes: 31 additions & 0 deletions src/azure-cli/azure/cli/command_modules/appservice/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def load_arguments(self, _):
local_context_attribute=LocalContextAttribute(name='web_name', actions=[LocalContextAction.SET],
scopes=['webapp', 'cupertino']))
c.argument('startup_file', help="Linux only. The web's startup file")
c.argument('sitecontainers_app', help="If true, a webapp which supports sitecontainers will be created", arg_type=get_three_state_flag())
c.argument('deployment_container_image_name', options_list=['--deployment-container-image-name', '-i'], help='Container image name from container registry, e.g. publisher/image-name:tag', deprecate_info=c.deprecate(target='--deployment-container-image-name'))
c.argument('container_registry_url', options_list=['--container-registry-url'], help='The container registry server url')
c.argument('container_image_name', options_list=['--container-image-name', '-c'],
Expand All @@ -172,6 +173,36 @@ def load_arguments(self, _):
c.ignore('language')
c.ignore('using_webapp_up')

with self.argument_context("webapp sitecontainers") as c:
c.argument('name', arg_type=webapp_name_arg_type, help='Name of the linux webapp')
c.argument("container_name", help='Name of the SiteContainer')
c.argument('slot', options_list=['--slot', '-s'], help='Name of the web app slot. Default to the productions slot if not specified.')

with self.argument_context("webapp sitecontainers create") as c:
c.argument("image", help='Image Name')
c.argument("target_port", help='Target port for SiteContainer')
c.argument("startup_cmd", help='Startup Command for the SiteContainer')
c.argument("is_main", help="true if the container is the main site container; false otherwise",
arg_type=get_three_state_flag())
c.argument("system_assigned_identity", help="If true, the system-assigned identity will be used for auth while pulling image",
arg_type=get_three_state_flag())
c.argument("user_assigned_identity", help='ClientID for the user-maganed identity which will be used for auth while pulling image')
c.argument("registry_username", help='username used for image registry auth')
c.argument("registry_password", help='password used for image registry auth')
c.argument("sitecontainers_spec_file", help="path to a json sitecontainer spec file containing a list of sitecontainers, other sitecontainer input args will be ignored if this arg is provided")

with self.argument_context("webapp sitecontainers update") as c:
c.argument("image", help='Image Name')
c.argument("target_port", help='Target port for SiteContainer')
c.argument("startup_cmd", help='Startup Command for the SiteContainer')
c.argument("is_main", help="true if the container is the main site container; false otherwise",
arg_type=get_three_state_flag())
c.argument("system_assigned_identity", help="If true, the system-assigned identity will be used for auth while pulling image",
arg_type=get_three_state_flag())
c.argument("user_assigned_identity", help='ClientID for the user-maganed identity which will be used for auth while pulling image')
c.argument("registry_username", help='username used for image registry auth')
c.argument("registry_password", help='password used for image registry auth')

with self.argument_context('webapp show') as c:
c.argument('name', arg_type=webapp_name_arg_type)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ def load_command_table(self, _):
g.generic_update_command('update', getter_name='get_webapp', setter_name='set_webapp',
custom_func_name='update_webapp', command_type=appservice_custom)

with self.command_group('webapp sitecontainers') as g:
g.custom_command('create', 'create_webapp_sitecontainers')
g.custom_command('update', 'update_webapp_sitecontainer')
g.custom_command('delete', 'delete_webapp_sitecontainer')
g.custom_command('show', 'get_webapp_sitecontainer')
g.custom_command('list', 'list_webapp_sitecontainers')
g.custom_command('status', 'get_webapp_sitecontainers_status')
g.custom_command('log', 'get_webapp_sitecontainer_log')

with self.command_group('webapp traffic-routing') as g:
g.custom_command('set', 'set_traffic_routing')
g.custom_show_command('show', 'show_traffic_routing')
Expand Down
Loading