Azure CLI Bash-将应用程序洞察资源附加到api管理

Azure CLI Bash-将应用程序洞察资源附加到api管理,bash,azure-cli,Bash,Azure Cli,我可以创建一个api管理实例 az apim create \ --name "$apimName" \ --resource-group "$resourceGroupName" \ --publisher-name 'Publisher' \ --publisher-email 'Myemail@email.com.au' \ --tags "${reso

我可以创建一个api管理实例

    az apim create \
        --name "$apimName" \
        --resource-group "$resourceGroupName" \
        --publisher-name 'Publisher' \
        --publisher-email 'Myemail@email.com.au' \
        --tags "${resourceTags[@]}"
我可以创建一个AppInsights实例

    az monitor app-insights component create \
        --app "${apimName}-appins" \
        --location "australiaeast" \
        --resource-group "$resourceGroupName" \
        --tags "${resourceTags[@]}"

如何将api细节附加到api管理?

尝试下面的命令,用您的值替换这些值

az resource create --resource-type 'Microsoft.ApiManagement/service/loggers' -g '<apim-group-name>' -n '<apim-name>/loggers/<appinsight-name>' --properties '{
    "loggerType":"applicationInsights",
    "description": null,
    "credentials": {
      "instrumentationKey": "<Instrumentation-Key-of-your-appinsight>"
    },
    "isBuffered": true,
    "resourceId": "/subscriptions/<subscription-id>/resourceGroups/<appinsight-group-name>/providers/microsoft.insights/components/<appinsight-name>"
}'
az资源创建--资源类型'Microsoft.ApiManagement/service/loggers'-g'


尝试下面的命令,将值替换为您的值

az resource create --resource-type 'Microsoft.ApiManagement/service/loggers' -g '<apim-group-name>' -n '<apim-name>/loggers/<appinsight-name>' --properties '{
    "loggerType":"applicationInsights",
    "description": null,
    "credentials": {
      "instrumentationKey": "<Instrumentation-Key-of-your-appinsight>"
    },
    "isBuffered": true,
    "resourceId": "/subscriptions/<subscription-id>/resourceGroups/<appinsight-group-name>/providers/microsoft.insights/components/<appinsight-name>"
}'
az资源创建--资源类型'Microsoft.ApiManagement/service/loggers'-g'


我可以在这里添加变量吗?“instrumentationKey”:“$instrumentationKey”。它为Application Insights Logger提供了无效的插装键,即使变量具有正确的key@David这是一个转义问题,因为json在
'
中,所以它不会被识别为var,我不是bash方面的专家,我建议您在一个新问题中提问。如果有人想知道如何克服Joy提到的单引号问题,请在所有地方使用双引号,并用反斜杠将所有引号转义,但包含json的外部引号除外-如下面的
\“
我可以在此处添加变量吗?”instrumentationKey:“$instrumentationKey”:”“。即使变量具有正确的key@David这是一个转义问题,因为json在
'
中,所以它不会被识别为var,我不是bash方面的专家,我建议你在一个新问题中提问。如果有人想知道如何克服Joy提到的单引号问题,请在任何地方使用双引号,并用反斜杠将所有引号转义,但包含json的外部引号除外,如下面的
\“