Skip to content

Commit 4cd5627

Browse files
authored
Merge pull request #229637 from MicrosoftDocs/release-asa-consumption
Publish release-asa-consumption to main--scheduled release at 3PM of 3/21
2 parents 3b9773b + 6cf67b6 commit 4cd5627

28 files changed

+1570
-65
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
---
2+
title: How to enable your own persistent storage in Azure Spring Apps with the Standard consumption plan
3+
description: Learn how to enable your own persistent storage in Azure Spring Apps.
4+
author: karlerickson
5+
ms.author: yitaopan
6+
ms.service: spring-apps
7+
ms.topic: how-to
8+
ms.date: 03/21/2023
9+
ms.custom: devx-track-java
10+
---
11+
12+
# How to enable your own persistent storage in Azure Spring Apps with the Standard consumption plan
13+
14+
> [!NOTE]
15+
> Azure Spring Apps is the new name for the Azure Spring Cloud service. Although the service has a new name, you'll see the old name in some places for a while as we work to update assets such as screenshots, videos, and diagrams.
16+
17+
**This article applies to:** ✔️ Standard consumption (Preview) ❌ Basic/Standard ❌ Enterprise
18+
19+
This article describes how to enable your own persistent storage in Azure Spring Apps.
20+
21+
Your own storage and the built-in persistent storage in Azure Spring Apps differ in the following ways:
22+
23+
- In built-in storage, artifacts generated by your application get uploaded into Azure Storage accounts. In your own storage, artifacts generated by your application get uploaded into a storage account that you control.
24+
25+
- In built-in storage, Microsoft Azure controls the encryption-at-rest and the lifetime management policies for those artifacts. In your own storage, you control the encryption-at-rest policy, the lifetime management policy, and network access.
26+
27+
You can also mount your own persistent storage not only to Azure Spring Apps but to other service instances in the environment such as Azure Container Apps. This capability is possible because your Azure Spring Apps instance is deployed in the Azure Container Apps environment.
28+
29+
## Prerequisites
30+
31+
- An Azure subscription. If you don't have a subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
32+
- [Azure CLI](/cli/azure/install-azure-cli) version 2.28.0 or higher.
33+
- An Azure Spring Apps Standard consumption plan service instance. For more information, see [Quickstart: Provision an Azure Spring Apps Standard consumption plan service instance](quickstart-provision-standard-consumption-service-instance.md).
34+
- A Spring app deployed to Azure Spring Apps. For more information, see [Quickstart: Build and deploy apps to Azure Spring Apps](quickstart-deploy-apps.md).
35+
36+
## Set up the environment
37+
38+
Use the following commands to set the following variables to the names of your resources and current region setting.
39+
40+
```bash
41+
RESOURCE_GROUP="<resource-group-name>"
42+
LOCATION="eastus"
43+
AZURE_CONTAINER_APPS_ENVIRONMENT="<Azure-Container-Apps-environment-name>"
44+
AZURE_SPRING_APPS_INSTANCE="<Azure-Spring-Apps-instance-name>"
45+
APP_NAME="<Spring-app-name>"
46+
```
47+
48+
## Set up a storage account
49+
50+
Use the following steps to create a storage account and establish a file share to mount to the Spring app.
51+
52+
1. Create an Azure Storage account by using the following commands. The `STORAGE_ACCOUNT_NAME` variable includes a randomly generated suffix to ensure uniqueness.
53+
54+
```azurecli
55+
STORAGE_ACCOUNT_NAME="myasastorageaccount$RANDOM"
56+
57+
az storage account create \
58+
--resource-group $RESOURCE_GROUP \
59+
--name $STORAGE_ACCOUNT_NAME \
60+
--location "$LOCATION" \
61+
--kind StorageV2 \
62+
--sku Standard_LRS \
63+
--query provisioningState \
64+
--enable-large-file-share
65+
```
66+
67+
This command returns a success message upon successful completion.
68+
69+
1. Create the Azure Storage file share by using the following commands:
70+
71+
```azurecli
72+
FILE_SHARE_NAME="<file-share-name>"
73+
74+
az storage share-rm create \
75+
--resource-group $RESOURCE_GROUP \
76+
--storage-account $STORAGE_ACCOUNT_NAME \
77+
--name $FILE_SHARE_NAME \
78+
--quota 1024 \
79+
--enabled-protocols SMB \
80+
--output table
81+
```
82+
83+
1. Get the Storage Account key by using the following command:
84+
85+
```azurecli
86+
STORAGE_ACCOUNT_KEY=$(az storage account keys list \
87+
--account-name $STORAGE_ACCOUNT_NAME \
88+
--query "[0].value" \
89+
--output tsv)
90+
```
91+
92+
The storage account key is required to create the storage link in your Azure Container Apps environment.
93+
94+
## Link the storage to the Azure Container Apps environment
95+
96+
Create the storage link in the Azure Container Apps environment by using the following commands. The `az containerapp env storage set` command creates a link between the environment and the file share created with the `az storage share-rm` command.
97+
98+
```azurecli
99+
STORAGE_MOUNT_NAME="<storage-account-name>"
100+
101+
az containerapp env storage set \
102+
--resource-group $RESOURCE_GROUP \
103+
--name $AZURE_CONTAINER_APPS_ENVIRONMENT \
104+
--storage-name $STORAGE_MOUNT_NAME \
105+
--azure-file-account-name $STORAGE_ACCOUNT_NAME \
106+
--azure-file-account-key $STORAGE_ACCOUNT_KEY \
107+
--azure-file-share-name $FILE_SHARE_NAME \
108+
--access-mode ReadWrite \
109+
--output table
110+
```
111+
112+
Now that the storage account and environment are linked, you can use the storage mount in your Azure Spring Apps instance.
113+
114+
## Add storage to an app
115+
116+
Add the persistent storage to your existing app by using the following command:
117+
118+
```azurecli
119+
az spring app append-persistent-storage \
120+
--resource-group $RESOURCE_GROUP \
121+
--service $AZURE_SPRING_APPS_INSTANCE \
122+
--name $APP_NAME \
123+
--persistent-storage-type AzureFileVolume \
124+
--mount-path /var/log/nginx \
125+
--storage-name STORAGE_MOUNT_NAME
126+
```
127+
128+
## Clean up resources
129+
130+
Be sure to delete the resources you created in this article when you no longer need them. To delete the resources, just delete the resource group that contains them. You can delete the resource group using the Azure portal. Alternately, to delete the resource group by using Azure CLI, use the following commands:
131+
132+
```azurecli
133+
echo "Enter the Resource Group name:" &&
134+
read resourceGroupName &&
135+
az group delete --name $resourceGroupName &&
136+
echo "Press [ENTER] to continue ..."
137+
```
138+
139+
## Next steps
140+
141+
- [Customer responsibilities for Azure Spring Apps Standard consumption plan in a virtual network](./standard-consumption-customer-responsibilities.md)
103 KB
Loading
92.2 KB
Loading
85.2 KB
Loading
58.6 KB
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)