本文介绍了检测在Azure IaaS VM上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过许多与我认为应该是一项相对简单的任务相关的帖子。作为我们的许可标准的一部分,我们检测我们是否在虚拟化环境中运行。但是,我们使用的某些标识符可能会因VM的重新分配
而发生变化,因此我们开始考虑使用Azure唯一ID(UUID)替换其中一些标识符。但为了做到这一点,我们需要对许可代码进行更改,以正确检测我们是否在一个蔚蓝的环境中运行。我见过许多与使用Azure SDK和RoleEnvironment有关
的帖子,但我相信在托管的IaaS VM上运行时(当复制必要的DLL时)这不起作用。

I have seen many posts relating to what I believe should be a relatively simple task. As part of our licensing criteria we detect if we are running within a virtualised environment. However some identifiers we were using can change as a result of deallocation of the VM’s and so we started looking into substituting some of these with the Azure Unique ID (UUID). But in order to do we so we need to make changes to our licensing code to correctly detect we are running in an azure environment. I’ve seen many posts relating to using the Azure SDK and RoleEnvironment, but I believe this doesn’t work when running on managed IaaS VM’s (When copying the requisite DLL’s across).

理想情况下,我们想要在.NET应用程序中使用某种方式,而不依赖于Azure SDK,我们可以正确识别Azure VM而不是标准VM。这可能包括注册表项,WMI查找等。

So ideally we want a way within a .NET application without having dependencies on the Azure SDK that we can correctly identify an Azure VM as opposed to a standard VM. This could include registry keys, WMI lookups etc.

推荐答案

https://azure.microsoft.com/en-us/blog/announcing-general- azure-instance-metadata-service / 的可用性

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/instance-metadata-service

使用此信息将是允许代码实现它的最佳方法是在Azure环境中运行而不是。 

Using this information would be the best way to allow your code to realize it is running in an Azure Environment vs not. 


这篇关于检测在Azure IaaS VM上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 00:07