Skip to content

Commit d31f24e

Browse files
authored
[App Service] Add support for linux sitecontainers (#30776)
1 parent cdbbe8e commit d31f24e

File tree

111 files changed

+73179
-228275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+73179
-228275
lines changed

src/azure-cli/azure/cli/command_modules/appservice/_help.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,9 @@
16581658
- name: Create a web app with a NodeJS 10.14 runtime and deployed from a local git repository.
16591659
text: >
16601660
az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName --runtime "node:12LTS" --deployment-local-git
1661+
- name: Create a web app which supports sitecontainers.
1662+
text: >
1663+
az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName --sitecontainers-app
16611664
- name: Create a web app with an image from DockerHub.
16621665
text: >
16631666
az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName -i nginx
@@ -2207,6 +2210,132 @@
22072210
crafted: true
22082211
"""
22092212

2213+
helps['webapp sitecontainers'] = """
2214+
type: group
2215+
short-summary: Manage linux web apps sitecontainers.
2216+
"""
2217+
2218+
helps['webapp sitecontainers create'] = """
2219+
type: command
2220+
short-summary: Create sitecontainers for a linux webapp
2221+
long-summary: |
2222+
Multiple sitecontainers can be added or updated at once by passing arg --sitecontainers-spec-file, which is the path to a json file containing an array of sitecontainer specs.
2223+
Example json file:
2224+
[
2225+
{
2226+
"name": "firstcontainer",
2227+
"properties": {
2228+
"image": "myregistry.io/firstimage:latest",
2229+
"targetPort": "80",
2230+
"isMain": true,
2231+
"environmentVariables": [
2232+
{
2233+
"name": "VARIABLE_1",
2234+
"value": "APPSETTING_NAME1"
2235+
}
2236+
],
2237+
"volumeMounts": [
2238+
{
2239+
"containerMountPath": "mountPath",
2240+
"readOnly": true,
2241+
"volumeSubPath": "subPath"
2242+
}
2243+
]
2244+
}
2245+
},
2246+
{
2247+
"name": "secondcontainer",
2248+
"properties": {
2249+
"image": "myregistry.io/secondimage:latest",
2250+
"targetPort": "3000",
2251+
"isMain": false,
2252+
"authType": "SystemIdentity",
2253+
"startUpCommand": "MyStartupCmd"
2254+
}
2255+
},
2256+
{
2257+
"name": "thirdcontainer",
2258+
"properties": {
2259+
"image": "myregistry.io/thirdimage:latest",
2260+
"targetPort": "3001",
2261+
"isMain": false,
2262+
"authType": "UserAssigned",
2263+
"userManagedIdentityClientId": "ClientID"
2264+
}
2265+
},
2266+
{
2267+
"name": "fourthcontainer",
2268+
"properties": {
2269+
"image": "myregistry.io/fourthimage:latest",
2270+
"targetPort": "3002",
2271+
"isMain": false,
2272+
"authType": "UserCredentials",
2273+
"userName": "Username",
2274+
"passwordSecret": "Password"
2275+
}
2276+
}
2277+
]
2278+
examples:
2279+
- name: Create a main sitecontainer for a linux webapp
2280+
text: az webapp sitecontainers create --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer --image MyImageRegistry.io/MyImage:latest --target-port 80 --is-main
2281+
- name : Create or update multiple sitecontainers for a linux webapp using a json sitecontainer-spec file
2282+
text: az webapp sitecontainers create --name MyWebApp --resource-group MyResourceGroup --sitecontainers-spec-file ./sitecontainersspec.json
2283+
"""
2284+
2285+
2286+
helps['webapp sitecontainers update'] = """
2287+
type: command
2288+
short-summary: Update an existing sitecontainer for a linux webapp
2289+
examples:
2290+
- name: Update a sitecontainer for a linux webapp
2291+
text: az webapp sitecontainers update --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer --image MyImageRegistry.io/MyImage:latest --target-port 3000 --is-main false
2292+
"""
2293+
2294+
2295+
helps['webapp sitecontainers delete'] = """
2296+
type: command
2297+
short-summary: Delete a sitecontainer for a linux webapp
2298+
examples:
2299+
- name: Delete a sitecontainer for a linux webapp
2300+
text: az webapp sitecontainers delete --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer
2301+
"""
2302+
2303+
2304+
helps['webapp sitecontainers show'] = """
2305+
type: command
2306+
short-summary: List the details of a sitecontainer for a linux webapp
2307+
examples:
2308+
- name: List the details of a sitecontainer for a linux webapp
2309+
text: az webapp sitecontainers show --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer
2310+
"""
2311+
2312+
2313+
helps['webapp sitecontainers list'] = """
2314+
type: command
2315+
short-summary: List all the sitecontainers for a linux webapp
2316+
examples:
2317+
- name: List all the sitecontainers for a linux webapp
2318+
text: az webapp sitecontainers list --name MyWebApp --resource-group MyResourceGroup
2319+
"""
2320+
2321+
2322+
helps['webapp sitecontainers status'] = """
2323+
type: command
2324+
short-summary: Get the status of a sitecontainer for a linux webapp
2325+
examples:
2326+
- name: Get the status of a sitecontainer for a linux webapp
2327+
text: az webapp sitecontainers status --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer
2328+
"""
2329+
2330+
helps['webapp sitecontainers log'] = """
2331+
type: command
2332+
short-summary: Get the logs of a sitecontainer for a linux webapp
2333+
examples:
2334+
- name: Get the logs of a sitecontainer for a linux webapp
2335+
text: az webapp sitecontainers log --name MyWebApp --resource-group MyResourceGroup --container-name MyContainer
2336+
"""
2337+
2338+
22102339
helps['webapp up'] = """
22112340
type: command
22122341
short-summary: >

src/azure-cli/azure/cli/command_modules/appservice/_params.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def load_arguments(self, _):
148148
local_context_attribute=LocalContextAttribute(name='web_name', actions=[LocalContextAction.SET],
149149
scopes=['webapp', 'cupertino']))
150150
c.argument('startup_file', help="Linux only. The web's startup file")
151+
c.argument('sitecontainers_app', help="If true, a webapp which supports sitecontainers will be created", arg_type=get_three_state_flag())
151152
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'))
152153
c.argument('container_registry_url', options_list=['--container-registry-url'], help='The container registry server url')
153154
c.argument('container_image_name', options_list=['--container-image-name', '-c'],
@@ -172,6 +173,40 @@ def load_arguments(self, _):
172173
c.ignore('language')
173174
c.ignore('using_webapp_up')
174175

176+
with self.argument_context("webapp sitecontainers") as c:
177+
c.argument('name', arg_type=webapp_name_arg_type, help='Name of the linux webapp')
178+
c.argument('resource_group', arg_type=resource_group_name_type)
179+
c.argument("container_name", help='Name of the SiteContainer')
180+
c.argument('slot', options_list=['--slot', '-s'], help='Name of the web app slot. Default to the productions slot if not specified.')
181+
182+
with self.argument_context("webapp sitecontainers create") as c:
183+
c.argument("image", help='Image Name')
184+
c.argument("target_port", help='Target port for SiteContainer')
185+
c.argument("startup_cmd", help='Startup Command for the SiteContainer')
186+
c.argument("is_main", help="true if the container is the main SiteContainer; false otherwise",
187+
arg_type=get_three_state_flag())
188+
c.argument("system_assigned_identity", options_list=['--system-assigned-identity', '--si'], help="If true, the system-assigned identity will be used for auth while pulling image",
189+
arg_type=get_three_state_flag())
190+
c.argument("user_assigned_identity", options_list=['--user-assigned-identity', '--ui'], help='ClientID for the user-maganed identity which will be used for auth while pulling image')
191+
c.argument("registry_username", help='Username used for image registry auth')
192+
c.argument("registry_password", help='Password used for image registry auth')
193+
c.argument("sitecontainers_spec_file", options_list=['--sitecontainers-spec-file', '--ssf'], 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")
194+
195+
with self.argument_context("webapp sitecontainers update") as c:
196+
c.argument("image", help='Image Name')
197+
c.argument("target_port", help='Target port for SiteContainer')
198+
c.argument("startup_cmd", help='Startup Command for the SiteContainer')
199+
c.argument("is_main", help="true if the container is the main site container; false otherwise",
200+
arg_type=get_three_state_flag())
201+
c.argument("system_assigned_identity", options_list=['--system-assigned-identity', '--si'], help="If true, the system-assigned identity will be used for auth while pulling image",
202+
arg_type=get_three_state_flag())
203+
c.argument("user_assigned_identity", options_list=['--user-assigned-identity', '--ui'], help='ClientID for the user-maganed identity which will be used for auth while pulling image')
204+
c.argument("registry_username", help='Username used for image registry auth')
205+
c.argument("registry_password", help='Password used for image registry auth')
206+
207+
with self.argument_context("webapp sitecontainers list") as c:
208+
c.argument('name', arg_type=webapp_name_arg_type, id_part=None, help='Name of the linux webapp')
209+
175210
with self.argument_context('webapp show') as c:
176211
c.argument('name', arg_type=webapp_name_arg_type)
177212

src/azure-cli/azure/cli/command_modules/appservice/commands.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ def load_command_table(self, _):
142142
g.generic_update_command('update', getter_name='get_webapp', setter_name='set_webapp',
143143
custom_func_name='update_webapp', command_type=appservice_custom)
144144

145+
with self.command_group('webapp sitecontainers') as g:
146+
g.custom_command('create', 'create_webapp_sitecontainers')
147+
g.custom_command('update', 'update_webapp_sitecontainer')
148+
g.custom_command('delete', 'delete_webapp_sitecontainer')
149+
g.custom_show_command('show', 'get_webapp_sitecontainer')
150+
g.custom_command('list', 'list_webapp_sitecontainers')
151+
g.custom_command('status', 'get_webapp_sitecontainers_status')
152+
g.custom_command('log', 'get_webapp_sitecontainer_log')
153+
145154
with self.command_group('webapp traffic-routing') as g:
146155
g.custom_command('set', 'set_traffic_routing')
147156
g.custom_show_command('show', 'show_traffic_routing')

0 commit comments

Comments
 (0)