You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @rajdhandus , thank you for your feedback. If you only have the IpAddress, there is no such method in the SDK to obtain the corresponding ResourceID. However, if you know the subscription and resourceName you are using, you can try the following method to obtain the ID: var sub = await ArmClient.GetSubscriptionResourceAsync(subId); var rg = await subscription.GetResourceGroupAsync(resourceGroupName); var publicIPAddressCollection = rg.GetPublicIPAddresses(); string yourIPAddress = ""; AsyncPageable<PublicIPAddressResource> getPublicIpAddressListResponseAP = publicIPAddressCollection.GetAllAsync(); List<PublicIPAddressResource> getPublicIpAddressListResponse = await getPublicIpAddressListResponseAP.ToEnumerableAsync(); foreach (PublicIPAddressResource resource in getPublicIpAddressListResponse) { if (resource.Data.IPAddress != null) { if (resource.Data.IPAddress == yourIPAddress) { Console.WriteLine($"Azure Resource ID of the public IP address {yourIPAddress} is {resource.Id}"); } } else { Console.WriteLine($"Public IP address {yourIPAddress} not found in your subscription."); } }
Output: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}
Is there a way to get the Azure Resource ID of a given Public IP if we know the IP address?
Input:- 40.81.207.37
Output:- /subscription/xxxx/resourceGroups/xxxx/providers/Microsoft.Network/publicIPAddresses/
Azure.ResourceManager.Network.PublicIPAddressCollection doesn't seem to have the necessary method..
The text was updated successfully, but these errors were encountered: