https://pulumi.com logo
#azure
Title
# azure
f

fast-vr-6049

07/17/2023, 10:42 PM
Hey folks! I've run into a problem with Network.Zone during my upgrade to Azure Native 2.0. For my C# stack, I import a non-Pulumi-managed DNS zone in order to create records, like so:
Copy code
var dnsZone = Zone.Get(
    name: dnsZoneResourceId.Split('/').Last(),
    id: dnsZoneResourceId
);
But this code throws an error when I run `pulumi preview`:
Copy code
error: Preview failed: autorest/azure: Service returned an error. Status=400 Code="NoRegisteredProviderFound" Message="No registered resource provider found for location 'global' and API version '2023-07-01-preview' for type 'dnszones'. The supported api-versions are '2015-05-04-preview, 2016-04
-01, 2017-09-01, 2017-09-15-preview, 2017-10-01, 2018-03-01-preview, 2018-05-01'. The supported locations are ', global'."
That last
supported locations
bit being
', global'
smacks of a typo to my sensibilities (
global
!=
, global
). I'm not sure if that typo was caused by Pulumi's automated consumption and parsing of the Azure API spec, or if someone over at Azure goofed when writing it. This is further frustrated by trying to go back to using the API version that 1.x used. When hovering over
Zone
, the doc comment mentions that the API version used in 1.x was
2018-05-01
, but
Pulumi.AzureNative.Network.V20180501
does not have a
Zone
resource defined in it. Indeed, it has very little in it at all; just four methods:
Copy code
GetDnsResourceReferenceByTarResources
GetDnsResourceReferenceByTarResourcesArgs
GetDnsResourceReferenceByTarResourcesInvokeArgs
GetDnsResourceReferenceByTarResourcesResult
On a similar note, these previous version comments might be in need of some checking. For example, the
VirtualNetwork
resource mentions that the previous version it used was
2020-11-01
, but
Pulumi.AzureNative.Network.V20201101
doesn't even exist! As it stands, it seems I am unable to migrate to Azure Native 2.0. Does anyone have suggestions for workarounds? Or perhaps are any of these problems I've listed worthy of filing issues in the Azure Native Github repo? Cheers! Update: I have happened upon a truly cursed potential workaround 🧵
I was peeking at the documentation for the
Get
method, and saw the third argument, the
CustomResourceOptions
. Inside there is a
Version
field, which the Docs say you should never edit. However, this was the only way I could find that would let me specify the version of the API to use, so I plugged it in:
Copy code
var dnsZone = Zone.Get(
    dnsZoneResourceId.Split('/').Last(),
    dnsZoneResourceId,
    new ()
    {
        Version = "1.104.0"
    }
);
Lo and behold, it seems to work. The DNS zone is read correctly and appropriately passed on to the other resources. I cannot in good faith recommend anyone actually do this, as it may have consequences I haven't yet encountered. But if, like me, you're desperate to get back to working order, you can give it a try?
r

rough-morning-53309

07/19/2023, 2:41 PM
Thank you @fast-vr-6049 for this feedback. We have a related issues open #2589 that we are looking into now. Feel free to upvote, add comments, or open an additional issue for this specific resource.
f

fast-vr-6049

07/20/2023, 7:13 PM
Thank you kindly, Monica! That does indeed seem to be what I'm experiencing, and it looks like a new version has been pushed to address it. Cheers!