Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags
more
Archives
Today
Total
관리 메뉴

클라우드 엔지니어 꿈나무

Azure - ARM Template 본문

Azure

Azure - ARM Template

새싹싹이 2024. 7. 27. 11:02

ARM Template

Azure가 생성하길 원하는 리소스를 JSON 파일로 표시

수정 및 배포 가능

자원 배포 방법 중 선언적 방법 - 최종 결과를 묘사하는 것

 

 

ARM Template에서 좌측에 표시된 것처럼 Parameter(매개 변수), Variables(변수), 리소스가 표시된다.

그 중, 리소스에서는 ARM Template이 생성할 리소스들을 볼 수 있고 만들어질 리소스는 하기와 같다.

1. 네트워크 인터페이스

2. 네트워크 보안 그룹

3. 네트워크

3. Pubilc IP

4. Virtual Machine

5. 스케쥴: VM 구성 중, 오후 7시에 VM이 꺼질 수 있도록 설정을 한 상태 

 

 

 

Virtual Machine 부분을 클릭하면 VM에 관한 설정들을 볼 수 있다.

            "name": "[parameters('virtualMachineName1')]",
            "type": "Microsoft.Compute/virtualMachines",
            "apiVersion": "2024-03-01",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName1'))]"
            ],
            "properties": {
                "hardwareProfile": {
                    "vmSize": "[parameters('virtualMachineSize')]"
                },
                "storageProfile": {
                    "osDisk": {
                        "createOption": "fromImage",
                        "managedDisk": {
                            "storageAccountType": "[parameters('osDiskType')]"
                        },
                        "deleteOption": "[parameters('osDiskDeleteOption')]"
                    },
                    "imageReference": {
                        "publisher": "MicrosoftWindowsServer",
                        "offer": "WindowsServer",
                        "sku": "2022-datacenter-azure-edition",
                        "version": "latest"
                    }
                },
                "networkProfile": {
                    "networkInterfaces": [
                        {
                            "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName1'))]",
                            "properties": {
                                "deleteOption": "[parameters('nicDeleteOption')]"
                            }
                        }
                    ]
                },
                "additionalCapabilities": {
                    "hibernationEnabled": false
                },
                "osProfile": {
                    "computerName": "[parameters('virtualMachineComputerName1')]",
                    "adminUsername": "[parameters('adminUsername')]",
                    "adminPassword": "[parameters('adminPassword')]",
                    "windowsConfiguration": {
                        "enableAutomaticUpdates": true,
                        "provisionVmAgent": true,
                        "patchSettings": {
                            "enableHotpatching": "[parameters('enableHotpatching')]",
                            "patchMode": "[parameters('patchMode')]"
                        }
                    }
                },
                "securityProfile": {
                    "securityType": "[parameters('securityType')]",
                    "uefiSettings": {
                        "secureBootEnabled": "[parameters('secureBoot')]",
                        "vTpmEnabled": "[parameters('vTPM')]"
                    }
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true
                    }
                }
            },
            "zones": [
                "[parameters('virtualMachine1Zone')]"
            ]
        },

 

 

매개 변수 부분의 드롭박스를 내리면 매개 변수가 지정되어 있는 것을 확인할 수 있으나 어떤 이름으로 설정되어 있는지는 이 화면에서 확인이 불가하고 다운로드를 통해서 확인할 수 있다.

 

 

다운로드를 받으면 하기와 같이 template.zip 폴더 안에 두 개의 json 파일이 있는 것을 볼 수 있다.

 

parameters.json에서 비밀번호 설정 필수! adminPassword로 매개 변수 설정되어 있다.

 

해당 json 파일을 azure 에 업로드 하기 위하여 리소스 그룹 중 초기에 자동 생성된 cloud-shell-storage-southeastasia으로 이동하여 파일 업로드

 

리소스 그룹 안에 있는 storage account > data storage > File shares > Browse > Add Directory로 디렉토리 생성 >

 

디렉토리 생성 확인 후, 해당 디렉토리 안에서 파일 업로드

 

cloud shell 진입

cd clouddrive

cd templates

dir

az deployment group create --resource-group optimized-vm-rg --template-file template.json --parameters parameters.json

 

 

리소스 그룹을 보면 리소스들이 생성된 것을 확인할 수 있다.