Azure Resource Manager(ARM) 및 CloudFormation(CF) 템플릿의 AllowedPattern 속성은 프로비저닝 요청을 보내기 전에 입력 유효성 검사를 수행합니다.
시작하기 전에
필요한 역할: sn.cmp.cloud_service_designer
이 태스크 정보
프로비저닝 요청을 클라우드로 보내기 전에 매개변수 값의 유효성을 검사하는 규칙을 제공할 수 있습니다. 유효성 검사에 실패할 경우 오류 메시지를 표시하려면 템플릿에 ConstraintDescription 속성을 지정합니다. ConstraintDescription 속성에서 오류 메시지를 사용자 지정하여 메시지를 명확하고 명시적으로 만들 수 있습니다. 일반적으로 CF 템플릿에는 AllowedPattern 및 ConstraintDescription 속성이 이미 있습니다. 이러한 속성이 없으면 다음 절차에서 설명하는 대로 추가할 수 있습니다.
프로시저
-
클라우드 관리자 포털에서 .
-
새 클라우드 템플릿을 만들려면 템플릿을 선택하거나 새로 만들기를 클릭합니다.
기존 템플릿을 선택하는 경우 템플릿의 이름을 바꿉니다.
-
본문 입력란에서 ARM 및 CF 템플릿을 다음과 같이 변경합니다.
-
ARM 템플릿에서 다음과 같이 변경합니다.
- 매개변수 메타데이터 섹션에서 SNC::Parameter::Metadata를 입력합니다.
- AllowedPattern 키를 추가하고 유효한 값 범위를 입력합니다.
- ConstraintDescription 키를 추가하고 오류 메시지를 입력합니다.
"parameters": {
"newStorageAccountName": {
"type": "string",
"metadata": {
"description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed.",
"SNC::Parameter::Metadata": {
"allowedPattern": "[0-9a-z]{1,11}",
"ConstraintDescription": "must be an alphanumeric "
}}}
-
CF 템플릿에서 다음을 변경합니다.
- AllowedPattern 키를 추가하고 유효한 값 범위를 입력합니다.
- ConstraintDescription 키를 추가하고 오류 메시지를 입력합니다.
"Parameters" : {
"SSHLocation" : {
"Description" : "The IP address range that can be used to SSH to the EC2 instances",
"Type": "String",
"MinLength": "9",
"MaxLength": "18",
"Default": "0.0.0.0/0",
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
}
}
-
제출을 클릭합니다.