posted by jgpaper 2017. 9. 11. 17:16

1. zure Stack에는 Azure CLI 설치

Azure Stack에는 Azure CLI 2.0 이상 버전이 필요 합니다. Azure CLI 설치 아래 링크를 참조 랍니다.

https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest

여기서는 Windows 기준으로 설치 합니다.

Install on Windows

You can install Azure CLI 2.0 with the MSI and use it in the Windows command-line, or you can install the CLI with apt-get on Bash on Ubuntu on Windows.

Install with MSI for the Windows command-line

To install the CLI on Windows and use it in the Windows command-line, download and run the MSI.

Install with apt-get for Bash on Ubuntu on Windows

  1. If you don't have Bash on Windows, install it.

  2. Open the Bash shell.

  3. Modify your sources list.

    bash
    echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \
         sudo tee /etc/apt/sources.list.d/azure-cli.list
    
  4. Run the following sudo commands:

    bash
    sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 417A0893
    sudo apt-get install apt-transport-https
    sudo apt-get update && sudo apt-get install azure-cli
    
  5. Run the CLI from the command prompt with the az command.

 

"...download and run the MSI." 에서 MSI 클릭해서 다운 받거나 "https://aka.ms/InstallAzureCliWindows" 에서 다운 받아 설치 합니다.

"Install" 버튼을 클릭합니다.

 

설치가 진행됩니다.

 

설치가 완료 후 "Finsh" 버튼을 클릭합니다.

설치 완료 정상적으로 설치가 되었는 아래 명령어롤 이용해 CMD 에서 버전을 확인 합니다.

 

정상적으로 Azure CLI 2.0 이상 버전이 걸치 되었습니다.


2. Azure Stack CA root 인증서 설정

인증을 위해  root 인증서를 받아서 Python 경로에 추가 해야 합니다.  Azure Stack 설명서(https://docs.microsoft.com/ko-kr/azure/azure-stack/azure-stack-connect-cli) 조금 다르게 나와 있습니다. 아래 Script MS 이동호 부장님께서 정리 하신 자료를 이용했습니다.

관리자권한 PowerShell 에서 실행 합니다.


$label = "AzureStackSelfSignedRootCert"

 

Write-Host "Getting certificate from the current user trusted store with subject CN=$label"

$root = Get-ChildItem Cert:\CurrentUser\Root | Where-Object Subject -eq "CN=$label" | select -First 1

if (-not $root)

{

Log-Error "Cerficate with subject CN=$label not found"

return

}

 

Write-Host "Exporting certificate"

Export-Certificate -Type CERT -FilePath root.cer -Cert $root

 

Write-Host "Converting certificate to PEM format"

certutil -encode root.cer root.pem

 

Write-Host "Extracting needed information from the cert file"

 

$md5Hash=(Get-FileHash -Path root.pem -Algorithm MD5).Hash.ToLower()

$sha1Hash=(Get-FileHash -Path root.pem -Algorithm SHA1).Hash.ToLower()

$sha256Hash=(Get-FileHash -Path root.pem -Algorithm SHA256).Hash.ToLower()

$issuerEntry = [string]::Format("# Issuer: {0}", $root.Issuer)

$subjectEntry = [string]::Format("# Subject: {0}", $root.Subject)

$labelEntry = [string]::Format("# Label: {0}", $label)

$serialEntry = [string]::Format("# Serial: {0}", $root.GetSerialNumberString().ToLower())

$md5Entry = [string]::Format("# MD5 Fingerprint: {0}", $md5Hash)

$sha1Entry = [string]::Format("# SHA1 Finterprint: {0}", $sha1Hash)

$sha256Entry = [string]::Format("# SHA256 Fingerprint: {0}", $sha256Hash)

$certText = (Get-Content -Path root.pem -Raw).ToString().Replace("`r`n","`n")

$rootCertEntry = "`n" + $issuerEntry + "`n" + $subjectEntry + "`n" + $labelEntry + "`n" + `

$serialEntry + "`n" + $md5Entry + "`n" + $sha1Entry + "`n" + $sha256Entry + "`n" + $certText

 

Write-Host "Adding the certificate content to Python Cert store"

 

Add-Content "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\CLI2\Lib\site-packages\certifi\cacert.pem" $rootCertEntry

 

Write-Host "Python Cert store was updated for allowing the azure stack CA root certificate"

      

3. Azure Stack 환경 등록 로그인

아래 Script 이용해서 Endpoint 환경 등록을 하고 로그인 합니다.

 

az cloud register -n AzureStackAdmin --endpoint-resource-manager "https://adminmanagement.local.azurestack.external" --suffix-storage-endpoint "local.azurestack.external" --suffix-keyvault-dns ".adminvault.local.azurestack.external"

 

az cloud set -n AzureStackAdmin

az cloud update --profile 2017-03-09-profile

az login -u [Azure AD 게정]

*참고 : PowerShell 에서 안되는 경우가 있습니다. CMD 이용해서 로그인 하십시오.