azure - 如何在 Data Factory v2 的自定义活动中读取安全字符串?
问题描述
我目前有一个使用自定义活动的 DFv2 管道,我正在尝试弄清楚如何读取传递给自定义活动的安全字符串。
我想这样做的原因是我的自定义活动可以将此安全字符串添加为对外部 API 的请求的一部分。
这是我的自定义活动的简化版本:
{
"name": "CustomActivity",
"type": "Custom",
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"typeProperties": {
"command": "CustomCode.exe",
"resourceLinkedService": {
"referenceName": "AzureStorageLinkedService",
"type": "LinkedServiceReference"
},
"folderPath": "foldercontainingcustomcode",
"extendedProperties": {
"url": "sampleUrl",
"apiKey": {
"type": "SecureString",
"value": "**********"
}
},
"referenceObjects": {
"linkedServices": [
{
"referenceName": "AzureStorageLinkedService",
"type": "LinkedServiceReference"
}
],
"datasets": [
]
}
},
"linkedServiceName": {
"referenceName": "AzureBatchLinkedService",
"type": "LinkedServiceReference"
}
}
这是一些示例自定义代码:
class Program
{
static void Main(string[] args)
{
dynamic activity = JsonConvert.DeserializeObject(File.ReadAllText("activity.json"));
dynamic apiKey = activity.typeProperties.extendedProperties.apiKey.value;
}
}
我的问题是:我怎样才能做到这一点,因为直接读取 apiKey 只会读取字符串 '*****' ?
解决方案
出于安全原因,数据工厂在任何情况下都不会返回安全字符串。
如果您想在自定义 exe 中使用密钥,可以将其作为 JSON 中的加密纯字符串保存,并使用您的证书或对称密钥在代码中对其进行解密。或者您可以引用 Azure Key Vault,以便您也可以在代码中访问它。
推荐阅读
- python - 如何在python中使用正则表达式提取特定单词之前的单词
- docker - Docker 容器不使用主机 DNS
- java - AES 算法在我的数据字符串中间返回垃圾字符
- android - Volley -JsonArrayRequest 显示错误
- digital-ocean - 次要阅读偏好
- ldap - 将 WSO2 IS 配置为外部 LDAP
- javascript - Twitter Bot Node.js 和 Twit 包
- iphone - iPhone Metal API 耗时过长(超过几秒)
- express - 如何在配置级别禁用 npm express 中的 Etag?
- azure - 在 Azure Ad 中添加可跨 AD 组访问的扩展属性