Title: | Interface to Azure Virtual Machine Instance Metadata |
Version: | 1.0.1 |
Description: | A simple interface to the instance metadata for a virtual machine running in Microsoft's 'Azure' cloud. This provides information about the VM's configuration, such as its processors, memory, networking, storage, and so on. Part of the 'AzureR' family of packages. |
URL: | https://github.com/Azure/AzureVMmetadata https://github.com/Azure/AzureR |
BugReports: | https://github.com/Azure/AzureVMmetadata/issues |
License: | MIT + file LICENSE |
Depends: | R (≥ 3.3) |
Imports: | openssl, httr (≥ 1.3) |
Suggests: | AzureAuth, AzureVM |
RoxygenNote: | 6.1.1 |
NeedsCompilation: | no |
Packaged: | 2020-10-14 15:05:43 UTC; hongo |
Author: | Hong Ooi [aut, cre], Microsoft [cph] |
Maintainer: | Hong Ooi <hongooi73@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2020-10-14 23:40:14 UTC |
Check if R is running in an Azure VM
Description
Check if R is running in an Azure VM
Usage
in_azure_vm()
get_vm_cert(nonce = NULL)
Arguments
nonce |
An optional string to use as a nonce. |
Details
These functions check if R is running in an Azure VM by attempting to contact the instance metadata host. in_azure_vm
simply returns TRUE or FALSE based on whether it succeeds. get_vm_cert
provides a stronger check, by retrieving the VM's certificate and throwing an error if this is not found. Note that you should still verify the certificate's authenticity before relying on it.
Value
For in_azure_vm
, a boolean. For get_vm_cert
, a PKCS-7 certificate object.
Metadata for an Azure VM
Description
Metadata for an Azure VM
Usage
instance
attested
events
update_instance_metadata()
update_attested_metadata(nonce = NULL)
update_scheduled_events()
Arguments
nonce |
For |
Format
instance
, attested
and events
are environments.
Details
The instance
, attested
and events
environments contain the instance metadata, attested metadata, and scheduled events respectively for a VM running in Azure. instance
and attested
are automatically populated when you load the AzureVMmetadata package, or you can manually populate them yourself with the update_instance_metadata
and update_attested_metadata
functions. events
is not populated at package startup, because calling the scheduled event service can require up to several minutes if it is not running already. You can manually populate it with the update_scheduled_events
function.
If AzureVMmetadata is loaded in an R session that is not running in an Azure VM, all the metadata environments will be empty.
Value
The updating functions return the contents of their respective environments as lists, invisibly.
See Also
Instance metadata service documentation
To obtain OAuth tokens from the metadata service, see AzureAuth::get_managed_token
Examples
## these will only be meaningful when run in an Azure VM
# all compute metadata
AzureVMmetadata::instance$compute
# VM name and ID
AzureVMmetadata::instance$compute$name
AzureVMmetadata::instance$compute$vmId
# VM resource details: subscription, resource group, resource ID
AzureVMmetadata::instance$compute$subscriptionId
AzureVMmetadata::instance$compute$resourceGroupName
AzureVMmetadata::instance$compute$resourceId
# all network metadata
AzureVMmetadata::instance$network
# IPv4 address details (1st network interface)
AzureVMmetadata::instance$network$interface[[1]]$ipv4