Skip to content

Commit f857107

Browse files
Merge pull request #230948 from davidsmatlak/ds-ama-update-deploy-cli
Adds Az CLI commands to managed apps deployment
2 parents 3d1f9cb + 65819c0 commit f857107

File tree

1 file changed

+157
-8
lines changed

1 file changed

+157
-8
lines changed

articles/azure-resource-manager/managed-applications/deploy-service-catalog-quickstart.md

Lines changed: 157 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: Deploy a service catalog managed application
3-
description: Describes how to deploy a service catalog's managed application for an Azure Managed Application.
3+
description: Describes how to deploy a service catalog's managed application for an Azure Managed Application using Azure PowerShell, Azure CLI, or Azure portal.
44
author: davidsmatlak
55
ms.author: davidsmatlak
66
ms.topic: quickstart
7-
ms.date: 03/14/2023
7+
ms.date: 03/16/2023
88
---
99

1010
# Quickstart: Deploy a service catalog managed application
@@ -55,6 +55,34 @@ $definitionid = (Get-AzManagedApplicationDefinition -ResourceGroupName appDefini
5555

5656
You use the `$definitionid` variable's value when you deploy the managed application.
5757

58+
# [Azure CLI](#tab/azure-cli)
59+
60+
To get the managed application's definition with Azure CLI, run the following commands.
61+
62+
In Visual Studio Code, open a new Bash terminal session and sign in to your Azure subscription. If you have Git installed, select Git Bash.
63+
64+
```azurecli
65+
az login
66+
```
67+
68+
The command opens your default browser and prompts you to sign in to Azure. For more information, go to [Sign in with Azure CLI](/cli/azure/authenticate-azure-cli).
69+
70+
From Azure CLI, get your managed application's definition. In this example, use the resource group name _appDefinitionGroup_ that was created when you deployed the managed application definition.
71+
72+
```azurecli
73+
az managedapp definition list --resource-group appDefinitionGroup
74+
```
75+
76+
The command lists all the available definitions in the specified resource group, like _sampleManagedApplication_.
77+
78+
Create a variable for the managed application definition's resource ID.
79+
80+
```azurecli
81+
definitionid=$(az managedapp definition show --resource-group appDefinitionGroup --name sampleManagedApplication --query id --output tsv)
82+
```
83+
84+
You use the `$definitionid` variable's value when you deploy the managed application.
85+
5886
# [Portal](#tab/azure-portal)
5987

6088
To get the managed application's definition from the Azure portal, use the following steps.
@@ -72,7 +100,7 @@ To get the managed application's definition from the Azure portal, use the follo
72100

73101
1. Select **Sample managed application** and then select **Create**.
74102

75-
The portal displays the managed application definitions that you created with the quickstart articles to publish an application definition.
103+
The portal displays the managed application definitions that you published with the quickstart articles.
76104

77105
:::image type="content" source="./media/deploy-service-catalog-quickstart/select-service-catalog-managed-application.png" alt-text="Screenshot that shows managed application definitions that you can deploy.":::
78106

@@ -99,7 +127,7 @@ $mrgname = $mrgprefix + $mrgtimestamp
99127
$mrgname
100128
```
101129

102-
The `$mrgprefix` and `$mrgtimestamp` variables are concatenated to create a resource group name like _rg-sampleManagedApplication-20230310100148_ that's stored in the `$mrgname` variable. You use the `$mrgname` variable's value when you deploy the managed application.
130+
The `$mrgprefix` and `$mrgtimestamp` variables are concatenated to create a managed resource group name like _rg-sampleManagedApplication-20230310100148_ that's stored in the `$mrgname` variable. The name's format `rg-{definitionName}-{dateTime}` is the same format as the portal's default value. You use the `$mrgname` variable's value when you deploy the managed application.
103131

104132
You need to provide several parameters to the deployment command for the managed application. You can use a JSON formatted string or create a JSON file. In this example, we use a JSON formatted string. The PowerShell escape character for the quote marks is the backtick (`` ` ``) character. The backtick is also used for line continuation so that commands can use multiple lines.
105133

@@ -125,6 +153,52 @@ The parameters to create the managed resources:
125153
- `storageAccountNamePrefix`: Use only lowercase letters and numbers and a maximum of 11 characters. For example, _demostg1234_. During deployment, the prefix is concatenated with a unique string to create a name globally unique across Azure. Although you're creating a prefix, the control checks for existing names in Azure and might post a validation message that the name already exists. If so, choose a different prefix.
126154
- `storageAccountType`: The default is Standard_LRS. The other options are Premium_LRS, Standard_LRS, and Standard_GRS.
127155

156+
# [Azure CLI](#tab/azure-cli)
157+
158+
Create a resource group for the managed application that's used during the deployment.
159+
160+
```azurecli
161+
az group create --name applicationGroup --location westus3
162+
```
163+
164+
You also need to create a name and path for the managed application resource group. The resource group is created when you deploy the managed application.
165+
166+
Run the following commands to create the managed resource group's path.
167+
168+
```azurecli
169+
mrgprefix='rg-sampleManagedApplication-'
170+
mrgtimestamp=$(date +%Y%m%d%H%M%S)
171+
mrgname="${mrgprefix}${mrgtimestamp}"
172+
subid=$(az account list --query [].id --output tsv)
173+
mrgpath="/subscriptions/$subid/resourceGroups/$mrgname"
174+
```
175+
176+
The `mrgprefix` and `mrgtimestamp` variables are concatenated to create a managed resource group name like _rg-sampleManagedApplication-20230310100148_ that's stored in the `mrgname` variable. The name's format:`rg-{definitionName}-{dateTime}` is the same format as the portal's default value. The `mrgname` and `subid` variable's are concatenated to create the `mrgpath` variable value that creates the managed resource group during the deployment.
177+
178+
You need to provide several parameters to the deployment command for the managed application. You can use a JSON formatted string or create a JSON file. In this example, we use a JSON formatted string. The PowerShell escape character for the quote marks is the backslash (`\`) character. The backslash is also used for line continuation so that commands can use multiple lines.
179+
180+
The JSON formatted string's syntax is as follows:
181+
182+
```json
183+
"{ \"parameterName\": {\"value\":\"parameterValue\"}, \"parameterName\": {\"value\":\"parameterValue\"} }"
184+
```
185+
186+
For readability, the completed JSON string uses the backtick for line continuation. The values are stored in the `params` variable that's used in the deployment command. The parameters in the JSON string are required to deploy the managed resources.
187+
188+
```azurecli
189+
params="{ \"appServicePlanName\": {\"value\":\"demoAppServicePlan\"}, \
190+
\"appServiceNamePrefix\": {\"value\":\"demoApp\"}, \
191+
\"storageAccountNamePrefix\": {\"value\":\"demostg1234\"}, \
192+
\"storageAccountType\": {\"value\":\"Standard_LRS\"} }"
193+
```
194+
195+
The parameters to create the managed resources:
196+
197+
- `appServicePlanName`: Create a plan name. Maximum of 40 alphanumeric characters and hyphens. For example, _demoAppServicePlan_. App Service plan names must be unique within a resource group in your subscription.
198+
- `appServiceNamePrefix`: Create a prefix for the plan name. Maximum of 47 alphanumeric characters or hyphens. For example, _demoApp_. During deployment, the prefix is concatenated with a unique string to create a name that's globally unique across Azure.
199+
- `storageAccountNamePrefix`: Use only lowercase letters and numbers and a maximum of 11 characters. For example, _demostg1234_. During deployment, the prefix is concatenated with a unique string to create a name globally unique across Azure. Although you're creating a prefix, the control checks for existing names in Azure and might post a validation message that the name already exists. If so, choose a different prefix.
200+
- `storageAccountType`: The default is Standard_LRS. The other options are Premium_LRS, Standard_LRS, and Standard_GRS.
201+
128202
# [Portal](#tab/azure-portal)
129203

130204
1. Provide values for the **Basics** tab and select **Next: Web App settings**.
@@ -157,7 +231,7 @@ The parameters to create the managed resources:
157231

158232
# [PowerShell](#tab/azure-powershell)
159233

160-
Run the following command to deploy the managed application from your Azure PowerShell session.
234+
Run the following command to deploy the managed application.
161235

162236
```azurepowershell
163237
New-AzManagedApplication `
@@ -175,10 +249,35 @@ The parameters used in the deployment command:
175249
- `Name`: Specify a name for the managed application. For this example, use _demoManagedApplication_.
176250
- `ResourceGroupName`: Name of the resource group you created for the managed application.
177251
- `Location`: Specify the region to deploy the resources. For this example, use _westus3_.
178-
- `ManagedResourceGroupName`: Uses the `$mrgname` parameters value. The managed resource group is created when the managed application is deployed.
252+
- `ManagedResourceGroupName`: Uses the `$mrgname` variable's value. The managed resource group is created when the managed application is deployed.
179253
- `ManagedApplicationDefinitionId`: Uses the `$definitionid` variable's value for the managed application definition's resource ID.
180254
- `Kind`: Specifies that type of managed application. This example uses _ServiceCatalog_.
181-
- `Parameter`: Uses the `$parms` variable's value in the JSON formatted string.
255+
- `Parameter`: Uses the `$params` variable's value in the JSON formatted string.
256+
257+
# [Azure CLI](#tab/azure-cli)
258+
259+
Run the following command to deploy the managed application.
260+
261+
```azurecli
262+
az managedapp create \
263+
--name demoManagedApplication \
264+
--resource-group applicationGroup \
265+
--location westus3 \
266+
--managed-rg-id $mrgpath \
267+
--managedapp-definition-id $definitionid \
268+
--kind ServiceCatalog \
269+
--parameters "$params"
270+
```
271+
272+
The parameters used in the deployment command:
273+
274+
- `name`: Specify a name for the managed application. For this example, use _demoManagedApplication_.
275+
- `resource-group`: Name of the resource group you created for the managed application.
276+
- `location`: Specify the region to deploy the resources. For this example, use _westus3_.
277+
- `managed-rg-id`: Uses the `$mrgpath` variable's value. The managed resource group is created when the managed application is deployed.
278+
- `managedapp-definition-id`: Uses the `$definitionid` variable's value for the managed application definition's resource ID.
279+
- `kind`: Specifies that type of managed application. This example uses _ServiceCatalog_.
280+
- `parameters`: Uses the `$params` variable's value in the JSON formatted string.
182281

183282
# [Portal](#tab/azure-portal)
184283

@@ -198,7 +297,7 @@ After the deployment is finished, you can check your managed application's statu
198297

199298
# [PowerShell](#tab/azure-powershell)
200299

201-
Run the following commands to check the managed application's status.
300+
Run the following command to check the managed application's status.
202301

203302
```azurepowershell
204303
Get-AzManagedApplication -Name demoManagedApplication -ResourceGroupName applicationGroup
@@ -210,6 +309,20 @@ Expand the properties to make it easier to read the `Properties` information.
210309
Get-AzManagedApplication -Name demoManagedApplication -ResourceGroupName applicationGroup | Select-Object -ExpandProperty Properties
211310
```
212311

312+
# [Azure CLI](#tab/azure-cli)
313+
314+
Run the following command to check the managed application's status.
315+
316+
```azurecli
317+
az managedapp list --resource-group applicationGroup
318+
```
319+
320+
The following command parses the data about the managed application to show only the application's name and provisioning state.
321+
322+
```azurecli
323+
az managedapp list --resource-group applicationGroup --query "[].{Name:name, provisioningState:provisioningState}"
324+
```
325+
213326
# [Portal](#tab/azure-portal)
214327

215328
Go to the resource group named **applicationGroup** and select **Overview**. The resource group contains your managed application named _demoManagedApplication_.
@@ -252,6 +365,34 @@ You can also list the deny assignments for the managed resource group.
252365
Get-AzDenyAssignment -ResourceGroupName $mrgname
253366
```
254367

368+
# [Azure CLI](#tab/azure-cli)
369+
370+
To display the managed resource group's resources, run the following command. You created the `$mrgname` variable when you created the parameters.
371+
372+
```azurecli
373+
az resource list --resource-group $mrgname
374+
```
375+
376+
Run the following command to list only the name, type, and provisioning state for the managed resources.
377+
378+
```azurecli
379+
az resource list --resource-group $mrgname --query "[].{Name:name, Type:type, provisioningState:provisioningState}"
380+
```
381+
382+
Run the following command to list the role assignment for the group that was used in the managed application's definition.
383+
384+
```azurecli
385+
az role assignment list --resource-group $mrgname
386+
```
387+
388+
The following command parses the data for the group's role assignment.
389+
390+
```azurecli
391+
az role assignment list --resource-group $mrgname --role Owner --query "[].{ResourceGroup:resourceGroup, GroupName:principalName, RoleDefinition:roleDefinitionId, Role:roleDefinitionName}"
392+
```
393+
394+
To review the managed resource group's deny assignments, use the Azure portal or Azure PowerShell commands.
395+
255396
# [Portal](#tab/azure-portal)
256397

257398
Go to the managed resource group with the name prefix **rg-sampleManagedApplication** and select **Overview** to display the resources that were deployed. The resource group contains an App Service, App Service plan, and storage account.
@@ -283,6 +424,14 @@ The command prompts you to confirm that you want to remove the resource group.
283424
Remove-AzResourceGroup -Name applicationGroup
284425
```
285426

427+
# [Azure CLI](#tab/azure-cli)
428+
429+
The command prompts for confirmation, and then returns you to command prompt while resources are being deleted.
430+
431+
```azurecli
432+
az group delete --resource-group applicationGroup --no-wait
433+
```
434+
286435
# [Portal](#tab/azure-portal)
287436

288437
1. From Azure portal **Home**, in the search field, enter _resource groups_.

0 commit comments

Comments
 (0)