从 Dynamics 365 插件访问非 Azure Web API(在本地 IIS 中托管)

Accessing non-Azure Web API (hosted in IIS locally) from Dynamics 365 plugin

大家早上好,

我正在尝试通过 Dynamics 365 插件从本地托管(在 IIS 中)Web API 中提取数据。我将 Web API 设置为使用 "Individual User Accounts" 并将其公开。当我测试它时,它在 Postman 中工作正常,因为我可以获得令牌,然后使用该令牌进行查询。

我的想法是,在插件中我会使用 HttpWebRequest 请求一个令牌,然后将该令牌用于将来的查询。

我的问题是我根本无法从 Dynamics 365 插件调用 Web API,因为当我尝试 运行 插件注册工具中的代码时出现安全错误。这是我对该主题的研究成果。

1.) 我无法访问 Web API 因为我没有注册它 in/as a "Microsoft Azure Web App." 我对此的问题是因为我们不打算使用 Azure (我不确定它是否符合该项目的安全规范)"do I have to register it with Azure?"

下面的引述来自 MSDN,主题是插件中的 Web 服务调用。我不确定我的设置是什么 missing/violating。

Web access

Sandboxed plug-ins and custom workflow activities can access the network through the HTTP and HTTPS protocols. This capability provides support for accessing popular web resources like social sites, news feeds, web services, and more. The following web access restrictions apply to this sandbox capability.

Only the HTTP and HTTPS protocols are allowed.

Access to localhost (loopback) is not permitted.

IP addresses cannot be used. You must use a named web address that requires DNS name resolution.

Anonymous authentication is supported and recommended. There is no provision for prompting the logged on user for credentials or saving those credentials.

2.) 我发现很多人说插件注册工具总是会抛出安全错误,因为我的插件被沙盒化了。每个人都只使用跟踪日志来调试吗?

3.) 我一直在研究 Dynamics 365 Web Hooks 的使用,但我需要此插件在 "RetrieveMultiple" 事件上执行。我可以用 D365 Web Hooks 做些什么吗?

非常感谢大家的帮助。祝你有美好的一天。

您的网络服务应该有一个 public 可访问的 https-URL,这样 dynamics 365 就可以从任何地方访问它。您应该通过登录机制保护您的网络服务。

作为测试、安全和配置建议,您不应在插件代码中添加 url、用户名和密码,而应使其在 crm 记录中可配置。因此,您可以在不同的 Web 服务实例上进行开发和测试,并且您的生产实例会连接到正确的 Web 服务,而无需在部署前更改代码。