-
Notifications
You must be signed in to change notification settings - Fork 1.6k
{Site} Add quickstart command and ARM template for Site + Config depl… #9594
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
8e36b7a
8c5a364
03b58cd
ca47836
5fa677c
b906a47
1f3ca3e
aac1e8b
819a00a
eb08a54
1f3e672
63d2ba2
e199fc3
c76d5fe
a23a275
ac97fe9
c4cfa7a
48c4586
5e75a10
4513703
b6bb095
3525f0c
4a62196
eb22336
b0eafab
4c2f6e2
55a54bf
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 |
|---|---|---|
|
|
@@ -14,3 +14,4 @@ | |
| from ._list import * | ||
| from ._show import * | ||
| from ._update import * | ||
| from ._quickstart import * | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from pathlib import Path | ||
| from azure.cli.core.aaz import ( # type: ignore[import-unresolved] | ||
| AAZCommand, | ||
| AAZStrArg, | ||
| AAZBoolArg, | ||
| AAZResourceGroupNameArg, | ||
| has_value, | ||
| register_command, | ||
| ) | ||
| from azure.cli.core.azclierror import ( # type: ignore[import-unresolved] | ||
| InvalidArgumentValueError, | ||
| FileOperationError, | ||
| CLIInternalError, | ||
| ) | ||
| from azure.cli.core import get_default_cli # type: ignore[import-unresolved] | ||
|
|
||
|
|
||
| def _resolve_template_path() -> Path: | ||
| # ...\azext_site\aaz\latest\site\_quickstart.py -> ...\azext_site\templates\infra\main.json | ||
| azext_root = Path(__file__).resolve().parents[3] # ...\azext_site | ||
| return azext_root / "templates" / "infra" / "main.json" | ||
|
|
||
|
|
||
| @register_command("site quickstart") | ||
| class Quickstart(AAZCommand): | ||
| """Quickstart: deploy internal ARM template to create Site + Config + ConfigRef.""" | ||
|
|
||
| _args_schema = None | ||
|
Comment on lines
+281
to
+285
|
||
|
|
||
| @classmethod | ||
| def _build_arguments_schema(cls, *args, **kwargs): | ||
| if cls._args_schema is not None: | ||
| return cls._args_schema | ||
|
|
||
| cls._args_schema = super()._build_arguments_schema(*args, **kwargs) | ||
| _args_schema = cls._args_schema | ||
|
|
||
| _args_schema.name = AAZStrArg( | ||
| options=["-n", "--name"], | ||
| required=True, | ||
| help="Site name (siteName).", | ||
| ) | ||
|
akanksha020901 marked this conversation as resolved.
|
||
|
|
||
| _args_schema.defaultconfiguration = AAZBoolArg( | ||
| options=["--defaultconfiguration", "--default-configuration"], | ||
| help="Trigger the internal ARM template flow (Site + Config + ConfigRef).", | ||
| ) | ||
|
|
||
| _args_schema.resource_group = AAZResourceGroupNameArg( | ||
| options=["-g", "--resource-group"], | ||
| required=True, | ||
| help="Resource group for deployment.", | ||
| ) | ||
|
|
||
| _args_schema.config_name = AAZStrArg( | ||
| options=["--config-name"], | ||
| help="Optional configName override. Default in template: '<siteName>-configuration'.", | ||
| ) | ||
|
|
||
| return cls._args_schema | ||
|
|
||
| def _handler(self, command_args): | ||
| super()._handler(command_args) | ||
|
|
||
| if not self.ctx.args.defaultconfiguration: | ||
| raise InvalidArgumentValueError("Specify --defaultconfiguration to run quickstart.") | ||
|
|
||
| return self.handle() | ||
|
|
||
| def handle(self): | ||
| template = _resolve_template_path() | ||
| if not template.exists(): | ||
| raise FileOperationError(f"Internal ARM template not found: {template}") | ||
|
|
||
| site_name = self.ctx.args.name.to_serialized_data() | ||
| rg = self.ctx.args.resource_group.to_serialized_data() | ||
|
|
||
| deployment_name = f"site-quickstart-{site_name}" | ||
|
|
||
| invoke_args = [ | ||
| "deployment", "group", "create", | ||
| "--name", deployment_name, | ||
| "--resource-group", rg, | ||
| "--template-file", str(template), | ||
| "--parameters", | ||
| f"siteName={site_name}", | ||
| ] | ||
|
|
||
| if has_value(self.ctx.args.config_name): | ||
| cfg = self.ctx.args.config_name.to_serialized_data() | ||
| invoke_args.append(f"configName={cfg}") | ||
|
|
||
| cli = get_default_cli() | ||
| rc = cli.invoke(invoke_args) | ||
| if rc != 0: | ||
| raise CLIInternalError("ARM deployment failed for site quickstart.") | ||
|
akanksha020901 marked this conversation as resolved.
Outdated
|
||
|
|
||
| return cli.result.result | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| { | ||
| "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
| "contentVersion": "1.0.0.0", | ||
| "parameters": { | ||
| "siteApiVersion": { | ||
| "type": "string", | ||
| "defaultValue": "2025-06-01" | ||
| }, | ||
| "configApiVersion": { | ||
| "type": "string", | ||
| "defaultValue": "2025-06-01" | ||
| }, | ||
| "configChildApiVersion": { | ||
| "type": "string", | ||
| "defaultValue": "2024-09-01-preview" | ||
| }, | ||
| "configRefApiVersion": { | ||
| "type": "string", | ||
| "defaultValue": "2025-06-01" | ||
| }, | ||
| "siteName": { | ||
| "type": "string" | ||
| }, | ||
| "description": { | ||
| "type": "string", | ||
| "defaultValue": "" | ||
| }, | ||
| "labels": { | ||
| "type": "object", | ||
| "defaultValue": {} | ||
| }, | ||
| "siteAddress": { | ||
| "type": "object", | ||
| "defaultValue": { | ||
| "streetAddress1": "", | ||
| "streetAddress2": "", | ||
| "city": "", | ||
| "stateOrProvince": "", | ||
| "country": "", | ||
| "postalCode": "" | ||
| } | ||
| }, | ||
| "location": { | ||
| "type": "string", | ||
| "defaultValue": "[resourceGroup().location]" | ||
| }, | ||
| "configName": { | ||
| "type": "string", | ||
| "defaultValue": "[concat(parameters('siteName'), '-configuration')]" | ||
| }, | ||
| "connectivityConfigName": { | ||
| "type": "string", | ||
| "defaultValue": "connectivityConfig1" | ||
| }, | ||
| "secretConfigName": { | ||
| "type": "string", | ||
| "defaultValue": "secretconfig1" | ||
| }, | ||
| "networkConfigName": { | ||
| "type": "string", | ||
| "defaultValue": "networkConfig1" | ||
| }, | ||
| "networkConfigurationKind": { | ||
| "type": "string", | ||
| "defaultValue": "LAN" | ||
| }, | ||
| "tsConfigName": { | ||
| "type": "string", | ||
| "defaultValue": "tsconfig1" | ||
| }, | ||
| "timeServerConfiguration": { | ||
| "type": "object", | ||
| "defaultValue": {} | ||
| }, | ||
| "connectivityConfiguration": { | ||
| "type": "object", | ||
| "defaultValue": {} | ||
| }, | ||
| "securityConfiguration": { | ||
| "type": "object", | ||
| "defaultValue": {} | ||
| }, | ||
| "networkConfiguration": { | ||
| "type": "object", | ||
| "defaultValue": { | ||
| "scenario": "Provisioning", | ||
| "ipAssignments": { | ||
| "ipAssignmentType": "Manual", | ||
| "ipv4": { | ||
| "addressRange": { | ||
| "startIp": "192.168.100.10", | ||
| "endIp": "192.168.100.50" | ||
| }, | ||
| "subnetMask": "255.255.255.0", | ||
| "defaultGateway": "192.168.100.1", | ||
| "dnsServers": [], | ||
| "vLanId": 0 | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "useArcGateway": { | ||
| "type": "bool", | ||
| "defaultValue": false | ||
| }, | ||
| "arcGatewayConfigName": { | ||
| "type": "string", | ||
| "defaultValue": "arcConfig1" | ||
| }, | ||
| "arcGatewayConfiguration": { | ||
| "type": "object", | ||
| "defaultValue": {} | ||
|
akanksha020901 marked this conversation as resolved.
Outdated
|
||
| } | ||
| }, | ||
| "variables": { | ||
| "siteId": "[resourceId('Microsoft.Edge/sites', parameters('siteName'))]", | ||
| "configId": "[resourceId('Microsoft.Edge/Configurations', parameters('configName'))]" | ||
| }, | ||
| "resources": [ | ||
| { | ||
| "type": "Microsoft.Edge/sites", | ||
| "apiVersion": "[parameters('siteApiVersion')]", | ||
| "name": "[parameters('siteName')]", | ||
| "properties": { | ||
| "displayName": "[parameters('siteName')]", | ||
| "description": "[parameters('description')]", | ||
| "siteAddress": { | ||
| "streetAddress1": "[parameters('siteAddress').streetAddress1]", | ||
| "streetAddress2": "[parameters('siteAddress').streetAddress2]", | ||
| "city": "[parameters('siteAddress').city]", | ||
| "stateOrProvince": "[parameters('siteAddress').stateOrProvince]", | ||
| "country": "[parameters('siteAddress').country]", | ||
| "postalCode": "[parameters('siteAddress').postalCode]" | ||
| }, | ||
| "labels": "[parameters('labels')]" | ||
| } | ||
| }, | ||
| { | ||
| "type": "Microsoft.Edge/Configurations", | ||
| "apiVersion": "[parameters('configApiVersion')]", | ||
| "name": "[parameters('configName')]", | ||
| "location": "[parameters('location')]", | ||
| "properties": {}, | ||
| "resources": [ | ||
| { | ||
| "type": "NetworkConfigurations", | ||
| "apiVersion": "[parameters('configChildApiVersion')]", | ||
| "name": "[parameters('networkConfigName')]", | ||
| "dependsOn": [ | ||
| "[resourceId('Microsoft.Edge/Configurations', parameters('configName'))]" | ||
| ], | ||
| "kind": "[parameters('networkConfigurationKind')]", | ||
| "properties": "[parameters('networkConfiguration')]" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "type": "Microsoft.Edge/configurationReferences", | ||
| "apiVersion": "[parameters('configRefApiVersion')]", | ||
| "name": "default", | ||
| "scope": "[variables('siteId')]", | ||
| "dependsOn": [ | ||
| "[variables('siteId')]", | ||
| "[variables('configId')]" | ||
| ], | ||
| "properties": { | ||
| "configurationResourceId": "[variables('configId')]" | ||
| } | ||
| } | ||
| ], | ||
| "outputs": { | ||
| "siteId": { | ||
| "type": "string", | ||
| "value": "[variables('siteId')]" | ||
| }, | ||
| "configId": { | ||
| "type": "string", | ||
| "value": "[variables('configId')]" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1 +1,5 @@ | ||||||
| #setup.cfg | ||||||
| #setup.cfg | ||||||
|
|
||||||
| [options.package_data] | ||||||
| azext_site = | ||||||
| templates\**\*.json | ||||||
|
||||||
| templates\**\*.json | |
| templates/**/*.json |
Uh oh!
There was an error while loading. Please reload this page.