Azure CLI를 사용하여 Azure 리소스 관리

Azure Resource Manager와 함께 Azure CLI를 사용하여 Azure 리소스를 관리하는 방법을 알아봅니다. 리소스 그룹 관리에 관한 자세한 내용은 Azure CLI를 사용하여 Azure 리소스 그룹 관리를 참조하세요.

기존 리소스 그룹에 리소스 배포

Azure CLI를 사용하여 Azure 리소스를 직접 배포하거나 Resource Manager 템플릿을 배포하여 Azure 리소스를 만들 수 있습니다.

리소스 배포

다음 스크립트는 스토리지 계정을 만듭니다.

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
echo "Enter the location (i.e. centralus):" &&
read location &&
echo "Enter the storage account name:" &&
read storageAccountName &&
az storage account create --resource-group $resourceGroupName --name $storageAccountName --location $location --sku Standard_LRS --kind StorageV2 &&
az storage account show --resource-group $resourceGroupName --name $storageAccountName 

템플릿 배포

다음 스크립트는 스토리지 계정을 만들기 위한 빠른 시작 템플릿 배포를 만듭니다. 자세한 내용은 빠른 시작: Visual Studio Code를 사용하여 ARM 템플릿 만들기를 참조하세요.

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
echo "Enter the location (i.e. centralus):" &&
read location &&
az deployment group create --resource-group $resourceGroupName --template-uri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.storage/storage-account-create/azuredeploy.json"

자세한 내용은 Resource Manager 템플릿과 Azure CLI로 리소스 배포를 참조하세요.

리소스 그룹 및 리소스 배포

리소스 그룹을 만들고 해당 그룹에 리소스를 배포할 수 있습니다. 자세한 내용은 리소스 그룹 만들기 및 리소스 배포를 참조하세요.

여러 구독 또는 리소스 그룹 간 리소스 배포

일반적으로 단일 리소스 그룹에 템플릿의 모든 리소스를 배포합니다. 그러나 일단의 리소스를 함께 배포하고 다른 리소스 그룹 또는 구독에 배치하려는 시나리오가 있습니다. 자세한 내용은 여러 구독 또는 리소스 그룹에 Azure 리소스 배포를 참조하세요.

리소스 삭제

다음 스크립트는 스토리지 계정을 삭제하는 방법을 보여 줍니다.

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
echo "Enter the storage account name:" &&
read storageAccountName &&
az storage account delete --resource-group $resourceGroupName --name $storageAccountName 

Azure Resource Manager가 리소스 삭제를 지시하는 방법에 대한 자세한 내용은 Azure Resource Manager 리소스 그룹 삭제를 참조하세요.

리소스 이동

다음 스크립트는 한 리소스 그룹에서 다른 리소스 그룹으로 스토리지 계정을 제거하는 방법을 보여 줍니다.

echo "Enter the source Resource Group name:" &&
read srcResourceGroupName &&
echo "Enter the destination Resource Group name:" &&
read destResourceGroupName &&
echo "Enter the storage account name:" &&
read storageAccountName &&
storageAccount=$(az resource show --resource-group $srcResourceGroupName --name $storageAccountName --resource-type Microsoft.Storage/storageAccounts --query id --output tsv) &&
az resource move --destination-group $destResourceGroupName --ids $storageAccount

자세한 내용을 보려면 새 리소스 그룹 또는 구독으로 리소스 이동을 참조하세요.

리소스 잠금

잠금은 조직의 다른 사용자가 실수로 Azure 구독, 리소스 그룹 또는 리소스와 같은 중요한 리소스를 삭제하거나 수정하는 것을 방지합니다.

다음 스크립트는 계정을 삭제할 수 없도록 스토리지 계정을 잠급니다.

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
echo "Enter the storage account name:" &&
read storageAccountName &&
az lock create --name LockSite --lock-type CanNotDelete --resource-group $resourceGroupName --resource-name $storageAccountName --resource-type Microsoft.Storage/storageAccounts 

다음 스크립트는 스토리지 계정에 대한 모든 잠금을 가져옵니다.

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
echo "Enter the storage account name:" &&
read storageAccountName &&
az lock list --resource-group $resourceGroupName --resource-name $storageAccountName --resource-type Microsoft.Storage/storageAccounts --parent ""

다음 스크립트는 스토리지 계정의 잠금을 삭제합니다.

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
echo "Enter the storage account name:" &&
read storageAccountName &&
lockId=$(az lock show --name LockSite --resource-group $resourceGroupName --resource-type Microsoft.Storage/storageAccounts --resource-name $storageAccountName --output tsv --query id)&&
az lock delete --ids $lockId

자세한 내용은 Azure 리소스 관리자를 사용하여 리소스 잠그기를 참조하세요.

리소스 태그 지정

태그를 지정하면 리소스 그룹 및 리소스를 논리적으로 구성하는 데 도움이 됩니다. 자세한 내용은 태그를 사용하여 Azure 리소스 구성을 참조하세요.

리소스에 대한 액세스 관리

Azure RBAC(Azure 역할 기반 액세스 제어)는 Azure에서 리소스에 대한 액세스를 관리하는 한 방법입니다. 자세한 내용은 Azure CLI를 사용하여 Azure 역할 할당 추가 또는 제거를 참조하세요.

다음 단계