PowerShell을 사용하여 Azure 알림 허브 만들기
이 샘플 PowerShell 스크립트는 샘플 Azure 알림 허브를 만듭니다.
참고 항목
Azure Az PowerShell 모듈을 사용하여 Azure와 상호 작용하는 것이 좋습니다. 시작하려면 Azure PowerShell 설치를 참조하세요. Az PowerShell 모듈로 마이그레이션하는 방법에 대한 자세한 내용은 Azure PowerShell을 AzureRM에서 Azure로 마이그레이션을 참조하세요.
이 샘플에는 Azure PowerShell Az 1.0 이상이 필요합니다. Get-Module -ListAvailable Az
를 실행하여 설치된 버전을 확인합니다.
설치해야 하는 경우 Azure PowerShell 모듈 설치를 참조하세요.
Connect-AzAccount를 실행하여 Azure에 로그인합니다.
필수 조건
- Azure 구독 - Azure 구독이 아직 없는 경우 시작하기 전에 체험 계정을 만듭니다.
샘플 스크립트
# Set appropriate values for these variables
$resourceGroupName = "<Enter a name for the resource group>"
$nhubnamespace = "<Enter a name for the notification hub namespace>"
$location = "East US"
# Create a resource group.
New-AzResourceGroup -Name $resourceGroupName -Location $location
# Create a namespace for the resource group
New-AzNotificationHubsNamespace -ResourceGroup $resourceGroupName -Namespace $nhubnamespace -Location $location
# Create an input JSON file that you use with the New-AzNotificationHub command
$text = '{"name": "MyNotificationHub", "Location": "East US", "Properties": { }}'
$text | Out-File "inputfile2.json"
# Create a notification hub
New-AzNotificationHub -ResourceGroup $resourceGroupName -Namespace $nhubnamespace -InputFile .\inputfile.json
배포 정리
샘플 스크립트를 실행한 후에는 다음 명령을 사용하여 리소스 그룹 및 해당 그룹에 연결된 모든 리소스를 제거할 수 있습니다.
Remove-AzResourceGroup -ResourceGroupName $resourceGroupName
스크립트 설명
이 스크립트는 다음 명령을 사용합니다.
명령 | 메모 |
---|---|
New-AzResourceGroup | 모든 리소스가 저장되는 리소스 그룹을 만듭니다. |
새 AzNotificationHubsNamespace | 알림 허브의 네임 스페이스를 만듭니다. |
새 AzNotificationHub | 알림 허브를 만듭니다. |
Remove-AzResourceGroup | 모든 중첩 리소스를 포함한 리소스 그룹을 삭제합니다. |
다음 단계
Azure PowerShell에 대한 자세한 내용은 Azure PowerShell 설명서를 참조하세요.