Azure Resource Managerを使用して1つのキューとイベントハブを配置した既存のサービスバスがあります。Service Busイベントハブ接続文字列の取得
ここで、ServiceBus.dllを使用せずにAzure PowerShellを使用して主キーと接続文字列を取得することに興味があります。出来ますか??
回避策として、既存のリソースを照会して必要な情報を取得するだけで、何も展開しないARMテンプレートを作成しました。
特定のサービス・バスの名前空間のための接続文字列とイベントハブ/キューの主キーを取得するテンプレート以下{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serviceBusNamespace": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "The name of the service bus namespace to create."
}
},
"resourceName": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "The name of the resource to be retreived."
}
},
"resourceType": {
"type": "string",
"minLength": 1,
"allowedValues": [
"queues",
"eventhubs"
],
"metadata": {
"description": "The type of the resource"
}
},
"policy": {
"type": "string",
"minLength": 1,
"defaultValue": "ManagePolicy",
"allowedValues": [
"ManagePolicy",
"SendPolicy",
"ListenPolicy"
],
"metadata": {
"description": "The type of the resource"
}
}
},
"variables": {
},
"resources": [ ],
"outputs": {
"connectionString": {
"type": "string",
"value": "[listKeys(resourceId(concat('Microsoft.ServiceBus/namespaces/',parameters('resourceType'),'/authorizationRules'),parameters('serviceBusNamespace'),parameters('resourceName'),parameters('policy')),'2015-08-01').primaryConnectionString]"
},
"primaryKey": {
"type": "string",
"value": "[listKeys(resourceId(concat('Microsoft.ServiceBus/namespaces/',parameters('resourceType'),'/authorizationRules'),parameters('serviceBusNamespace'),parameters('resourceName'),parameters('policy')),'2015-08-01').primaryKey]"
}
}
}
それはリソースのためクエリにARMのテンプレートを使用して、実際には何も展開しないために悪用されていますか?で定義されととのConnectionStringプロパティ名こと
PowerShell内ARMテンプレートの出力をキャプチャするEDIT が
$ep = New-AzureRmResourceGroupDeployment -Name "getEventHub" -ResourceGroupName myResourceGroup -Mode Incremental -TemplateFile getEventHub.json -TemplateParameterFile getEventHub.param.json
$RuleConnString = $ep.Outputs.connectionString.value
$RulePrimaryKey = $ep.Outputs.primaryKey.value
以下のコードを使用注主キーは同じです私のテンプレートファイル
EDIT 2 ARMテンプレートを再実行してイベントハブを2回展開すると、以下のエラーが発生します。
ARMテンプレートを使用して詳細を照会する以外の方法はありません。
Node.jsのサンプルがありますか? PowerJhellのNodeJSからの出力を簡単に消費することは可能ですか? – Sandesh
NodeJSはpowershellと混合するのではなく、あなたがやっていることのためのインターフェースやGUIを作ろうと思っていたら。私は何を見つけることができます。 Powershellコマンドレットは、特に「* -azurerm」で始まります。それらは腕のテンプレートとよく混じり合っています –
現在、チームはPowerShellを使用しているオートメーションにのみ焦点を当てています。だから私は今NodeJSが助けになるとは思わない。それまでは私はARMに固執するでしょう。ありがとう:) – Sandesh