Hi :wave::skin-tone-2: Is it possible to retrieve ...
# azure
r
Hi 👋🏻 Is it possible to retrieve the IP address of a deployed Function app? I can’t find it in either the classic or native Azure providers, and am in need of it for an
A
record for an apex domain custom hostname. The IP address is displayed in the Azure Portal next to the custom domain verification ID, but I can’t find it in the equivalent place in the provider APIs. Any ideas?
Looks like it’s static and needs to be retrieved “by hand” post-deployment 😕
a
I have to do the same thing with a CosmosDB resource. There is a method in the new azure-native SDK that allows me to do this:
Copy code
import * as documentDb from "@pulumi/azure-native/documentdb/v20210301preview";

<snip out most of creating cosmos db account>
var dbAccount = new documentDb.DatabaseAccount();

const resp:pulumi.Output<documentDb.ListDatabaseAccountConnectionStringsResult> = pulumi
.all([dbAccount.name, resourceGroup.name])
.apply(([cosmosdbAccountName, resourceGroupName]) => documentDb.listDatabaseAccountConnectionStrings({
    accountName: cosmosdbAccountName,
    resourceGroupName: resourceGroupName,
}));

this.cosmosDbPrimaryConnectionString = resp.apply(r => r.connectionStrings![0].connectionString);
this.cosmosDbPrimaryReadOnlyConnectionString =resp.apply(r => r.connectionStrings![2].connectionString);
resp
,
this.cosmosDbPrimaryConnectionString
,
this.cosmosDbPrimaryReadOnlyConnectionString
are all
pulumi.Output<T>
that I can use later on to retrieve and use the actual values.
r
Nice one, thanks @ancient-megabyte-79588. None of the available `get`/`list` methods in the
web
namespace obviously map to this, so I’ve gone ahead with a pure-Node DNS lookup
If anyone’s interested:
Copy code
import { promises as dnsLookup } from "dns";

const aRecords = pulumi.interpolate`${functionAppName}.<http://azurewebsites.net|azurewebsites.net>`
  .apply(
     async d => (await dnsLookup.resolve4(d))
       .map(ipv4Address => ({ ipv4Address })));

const a = new dns.RecordSet(customHostname, {
  recordType: "A",
  resourceGroupName: "rg-dns",
  relativeRecordSetName: "@",
  zoneName: zone.name,
  aRecords
});
👍 1
a
what pulumi resource are you creating? I have done nothing with pulumi and web apps yet.
r
It’s a
RecordSet
from
@pulumi/azure-native/network/v20180501
— beware the versionless
RecordSet
resource and issue #583