Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/cs-getcustomdomainverificationid/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using Pulumi.AzureNative.App;

return await Pulumi.Deployment.RunAsync(() =>
{
var azureDomainVerificationId = GetCustomDomainVerificationId.Invoke().Apply(x => x.Value);

return new Dictionary<string, object?>
{
["domainVerificationId"] = azureDomainVerificationId
};
});
7 changes: 7 additions & 0 deletions examples/cs-getcustomdomainverificationid/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: cs-getcustomdomainverificationid
description: An Azure Native C# Pulumi program calling the App.GetCustomDomainVerificationId invoke
runtime: dotnet
config:
pulumi:tags:
value:
pulumi:template: azure-csharp
14 changes: 14 additions & 0 deletions examples/cs-getcustomdomainverificationid/azn-3716-azcore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi" Version="3.*" />
<PackageReference Include="Pulumi.AzureNative" Version="2.*" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions examples/examples_dotnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ func TestPortalDashboardDotnet(t *testing.T) {
integration.ProgramTest(t, &test)
}

func TestGetCustomDomainVerificationId(t *testing.T) {
test := getCsharpBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: filepath.Join(getCwd(t), "cs-getcustomdomainverificationid"),
})

integration.ProgramTest(t, &test)
}

func TestPulumiExamples(t *testing.T) {
for _, example := range pexamples.GetTestsByTags(pexamples.AzureNativeProvider, pexamples.CS) {
t.Run(example.Dir, func(t *testing.T) {
Expand Down
8 changes: 6 additions & 2 deletions provider/pkg/azure/client_azcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,12 @@ func (c *azCoreClient) Post(ctx context.Context, id string, bodyProps map[string
return nil, runtime.NewResponseError(resp)
}

var responseBody map[string]interface{}
err = runtime.UnmarshalAsJSON(resp, &responseBody)
return readResponse(resp)
}

func readResponse(resp *http.Response) (any, error) {
var responseBody any
err := runtime.UnmarshalAsJSON(resp, &responseBody)
return responseBody, handleAzCoreResponseError(err, resp)
}

Expand Down
20 changes: 20 additions & 0 deletions provider/pkg/azure/client_azcore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,3 +677,23 @@ func (errorReadCloser) Read(p []byte) (n int, err error) {
func (errorReadCloser) Close() error {
return nil
}

func TestPostResponsesCanBeAnything(t *testing.T) {
t.Run("string", func(t *testing.T) {
resp := &http.Response{
Body: io.NopCloser(strings.NewReader(`"hello"`)),
}
val, err := readResponse(resp)
require.NoError(t, err)
assert.Equal(t, "hello", val)
})

t.Run("object", func(t *testing.T) {
resp := &http.Response{
Body: io.NopCloser(strings.NewReader(`{"k": 1}`)),
}
val, err := readResponse(resp)
require.NoError(t, err)
assert.Equal(t, map[string]any{"k": 1.0}, val)
})
}