在ARM模板中使用用户名和密码进行API连接的解决方法如下:
"parameters": {
"username": {
"type": "string",
"metadata": {
"description": "API连接的用户名"
}
},
"password": {
"type": "securestring",
"metadata": {
"description": "API连接的密码"
}
}
}
reference()
获取定义的参数值,然后在API连接字符串中使用这些值。"resources": [
{
"type": "Microsoft.Web/connections",
"name": "apiConnection",
"apiVersion": "2021-01-01",
"location": "[resourceGroup().location]",
"properties": {
"displayName": "API连接",
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/api-name')]"
},
"parameterValues": {
"username": {
"value": "[reference(parameters('username'))]"
},
"password": {
"value": "[reference(parameters('password'))]"
}
}
}
}
]
az deployment group create --resource-group --template-file --parameters username= password=
请注意,上述示例中的api-name
应替换为实际的API名称,以及其他必要的属性和参数根据情况进行调整。
上一篇:API连接 - 将C#示例迁移到PHP(Wordpress)
下一篇:API连接不到在Azure上的IdentityServer4,除非context.Request.Scheme设置为'https”。