Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DevOps] Table Storage용 bicep 파일 만들기 #283 #292

Merged
merged 21 commits into from
Sep 14, 2024

Conversation

tae0y
Copy link
Contributor

@tae0y tae0y commented Sep 1, 2024

관련이슈 #283 #213
관련PR #281

실행/배포

  • 배포 명령어
# 기본 변수설정
AZURE_ENV_NAME="tae0y"
AZURE_RESOURCE_GROUP="rg-$AZURE_ENV_NAME"

# 리소스 배포
az deployment group create \
-g $AZURE_RESOURCE_GROUP \
--template-file ./infra/aspire.bicep \
--parameters environmentName=$AZURE_ENV_NAME \
--parameters location=$(azd env get-value AZURE_LOCATION) \
--parameters tableNames=events,tests #여기에 생성할 테이블 목록을 쉼표로 구분하여 작성

테스트

  • 테스트 명령어
# 기본 변수설정
AZURE_ENV_NAME="tae0y"
AZURE_RESOURCE_GROUP="rg-$AZURE_ENV_NAME"

# 생성된 테이블 목록 조회
KEY_VAULT_NAME=$(az keyvault list --resource-group $AZURE_RESOURCE_GROUP --query "[].name" --output tsv)
export AZURE_STORAGE_CONNECTION_STRING=$(az keyvault secret show --name storage-connection-string --vault-name $KEY_VAULT_NAME | jq -r '.value')
az storage table list --connection-string $AZURE_STORAGE_CONNECTION_STRING
  • 테스트결과
[
  {
    "name": "events"
  },
  {
    "name": "tests"
  }
]

@tae0y
Copy link
Contributor Author

tae0y commented Sep 1, 2024

트러블슈팅 [완료 : 현재는 안됨]

확인결과 현재는 아래 증상이 정상이고, 차후에 azure.yaml에서 별도 설정을 해야함!

이런 증상이 있어 트러블슈팅 중인데 실마리를 찾지 못하고 있습니다.
azd up에서 infra/storage-account.bicep를 인식하지 못하는 것 같아서,
이걸 인식시켜줄 방법을 찾아보고 있어요. 이 방향이 맞을까요? @justinyoo

증상을 해결해주는 것들, 하지만 여전히 azd up만으로는 배포되지 않음

  • az deployment group create --resource-group rg-tae0y --template-file infra/storage-account.bicep처럼 bicep을 특정하면 배포가 잘 됨
  • azd infra synth로 생성되는 resources.bicep에서 다음 구문을 추가하면 증상 해소됨
module storageAccount 'storage-account.bicep' = {
    name: 'storageAccount'
}

시도해도 증상이 해소되지 않았던 것들

  • infra/storage-account.bicep을 추가했으나 azd up으로 배포되지 않음
  • infra/storage-account.bicep를 자동으로 감지하지 못하는 것 같아 azure.yaml 수정했으나 증상 해소되지 않음
  • infra/main.bicep으로 이름 바꿔서 다시 진행해보았지만 증상 해소되지 않음
  • azd 업그레이드
# 다음 구문을 azure.yaml에 추가함
infra:
  bicep: ./infra/storage-account.bicep
# az 버전정보
→ az version
{
  "azure-cli": "2.63.0",
  "azure-cli-core": "2.63.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {
    "containerapp": "0.3.53"
  }
}
# azd 버전정보
→ azd --version
azure-cli                         2.63.0

core                              2.63.0
telemetry                          1.1.0

Extensions:
containerapp                      0.3.53

Dependencies:
msal                              1.30.0
azure-mgmt-resource               23.1.1

Python location '/opt/homebrew/Cellar/azure-cli/2.63.0/libexec/bin/python'
Extensions directory '/Users/bachtaeyeong/.azure/cliextensions'

Python (Darwin) 3.11.9 (main, Apr  2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.3.9.4)]

Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.

@tae0y tae0y marked this pull request as draft September 1, 2024 13:42
Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테이블 배열 넘기는 부분은 aspire.bicep 파일에서 모듈을 불러오는 것으로 하면서 거기서 넘겨주면 됩니다.

@tae0y tae0y marked this pull request as ready for review September 3, 2024 14:52
@tae0y
Copy link
Contributor Author

tae0y commented Sep 3, 2024

해당 테이블 스토리지를 참조해서 의존객체 생성하는 부분은
@sikutisa 일구님 작업 준비중입니다!

Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

몇가지 추가적으로 고려해 볼 사항을 리뷰 코멘트로 남겨뒀습니다.

Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 컨테이너 앱을 키볼트에 연결시키는 부분이 없는데, 이건 같이 고민을 좀 해 보시죠.

@tae0y
Copy link
Contributor Author

tae0y commented Sep 7, 2024

현재 컨테이너 앱을 키볼트에 연결시키는 부분이 없는데, 이건 같이 고민을 좀 해 보시죠.

권한 설정하는 부분은 아래와 같이 구문을 추가해두었습니다
principalId가 무엇인지 어떻게 가져올지는 조사 중입니다.

// Role Assignment for Key Vault secret : creator admin, apiapp user
resource keyVaultSecretRoleAssignment 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
    name: guid(resourceGroup().id, resolvedKeyVaultName, 'secret-role-assignment')
    properties: {
        principalId: creatorAdminPrincipalId
        roleDefinitionId: '00482A5A-887F-4FB3-B363-3B7FE8E74483' // administrator role
    }
}

resource keyVaultSecretApiAppRoleAssignment 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
    name: guid(resourceGroup().id, resolvedKeyVaultName, 'secret-apiapp-role-assignment')
    properties: {
        principalId: apiAppUserPrincipalId
        roleDefinitionId: '4633458B-17DE-408A-B874-0445C86B69E6' // secret user role
    }
}

@tae0y
Copy link
Contributor Author

tae0y commented Sep 7, 2024

커넥션스트링 자체는 잘 저장하고,
해당 문자열을 조회해서(Azure portal에서 넣어주신 어드민 권한으로)
테이블이 잘 생성되었는지까지는 테스트 했습니다!

@tae0y tae0y requested a review from justinyoo September 11, 2024 14:05
Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

질문을 남겼습니다!

Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다! LGTM

@justinyoo justinyoo merged commit a50f07d into aliencube:main Sep 14, 2024
1 check passed
@tae0y tae0y deleted the feature/283-table-storage-bicep branch September 14, 2024 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DevOps] Table Storage용 bicep 파일 만들기
2 participants