The azure-native:apimanagement:Api resource, part of the Pulumi Azure Native provider, defines an API within Azure API Management: its path, protocols, backend service URL, authentication requirements, and API type. This guide focuses on four capabilities: creating APIs with OAuth2 authentication, importing from OpenAPI specifications, API versioning and revision workflows, and protocol-specific API types.
APIs belong to an API Management service instance and may reference OAuth2 servers, OpenID Connect providers, version sets, or source APIs for cloning. The examples are intentionally small. Combine them with your own API Management service, authentication providers, and backend services.
Create an API with OAuth2 authentication
Most API Management deployments begin by defining an API with its path, protocols, and backend service URL, often with OAuth2 authentication to secure access.
import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";
const api = new azure_native.apimanagement.Api("api", {
apiId: "tempgroup",
authenticationSettings: {
oAuth2: {
authorizationServerId: "authorizationServerId2283",
scope: "oauth2scope2580",
},
},
description: "apidescription5200",
displayName: "apiname1463",
path: "newapiPath",
protocols: [
azure_native.apimanagement.Protocol.Https,
azure_native.apimanagement.Protocol.Http,
],
resourceGroupName: "rg1",
serviceName: "apimService1",
serviceUrl: "http://newechoapi.cloudapp.net/api",
subscriptionKeyParameterNames: {
header: "header4520",
query: "query3037",
},
});
import pulumi
import pulumi_azure_native as azure_native
api = azure_native.apimanagement.Api("api",
api_id="tempgroup",
authentication_settings={
"o_auth2": {
"authorization_server_id": "authorizationServerId2283",
"scope": "oauth2scope2580",
},
},
description="apidescription5200",
display_name="apiname1463",
path="newapiPath",
protocols=[
azure_native.apimanagement.Protocol.HTTPS,
azure_native.apimanagement.Protocol.HTTP,
],
resource_group_name="rg1",
service_name="apimService1",
service_url="http://newechoapi.cloudapp.net/api",
subscription_key_parameter_names={
"header": "header4520",
"query": "query3037",
})
package main
import (
apimanagement "github.com/pulumi/pulumi-azure-native-sdk/apimanagement/v3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apimanagement.NewApi(ctx, "api", &apimanagement.ApiArgs{
ApiId: pulumi.String("tempgroup"),
AuthenticationSettings: &apimanagement.AuthenticationSettingsContractArgs{
OAuth2: &apimanagement.OAuth2AuthenticationSettingsContractArgs{
AuthorizationServerId: pulumi.String("authorizationServerId2283"),
Scope: pulumi.String("oauth2scope2580"),
},
},
Description: pulumi.String("apidescription5200"),
DisplayName: pulumi.String("apiname1463"),
Path: pulumi.String("newapiPath"),
Protocols: pulumi.StringArray{
pulumi.String(apimanagement.ProtocolHttps),
pulumi.String(apimanagement.ProtocolHttp),
},
ResourceGroupName: pulumi.String("rg1"),
ServiceName: pulumi.String("apimService1"),
ServiceUrl: pulumi.String("http://newechoapi.cloudapp.net/api"),
SubscriptionKeyParameterNames: &apimanagement.SubscriptionKeyParameterNamesContractArgs{
Header: pulumi.String("header4520"),
Query: pulumi.String("query3037"),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var api = new AzureNative.ApiManagement.Api("api", new()
{
ApiId = "tempgroup",
AuthenticationSettings = new AzureNative.ApiManagement.Inputs.AuthenticationSettingsContractArgs
{
OAuth2 = new AzureNative.ApiManagement.Inputs.OAuth2AuthenticationSettingsContractArgs
{
AuthorizationServerId = "authorizationServerId2283",
Scope = "oauth2scope2580",
},
},
Description = "apidescription5200",
DisplayName = "apiname1463",
Path = "newapiPath",
Protocols = new[]
{
AzureNative.ApiManagement.Protocol.Https,
AzureNative.ApiManagement.Protocol.Http,
},
ResourceGroupName = "rg1",
ServiceName = "apimService1",
ServiceUrl = "http://newechoapi.cloudapp.net/api",
SubscriptionKeyParameterNames = new AzureNative.ApiManagement.Inputs.SubscriptionKeyParameterNamesContractArgs
{
Header = "header4520",
Query = "query3037",
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.apimanagement.Api;
import com.pulumi.azurenative.apimanagement.ApiArgs;
import com.pulumi.azurenative.apimanagement.inputs.AuthenticationSettingsContractArgs;
import com.pulumi.azurenative.apimanagement.inputs.OAuth2AuthenticationSettingsContractArgs;
import com.pulumi.azurenative.apimanagement.inputs.SubscriptionKeyParameterNamesContractArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var api = new Api("api", ApiArgs.builder()
.apiId("tempgroup")
.authenticationSettings(AuthenticationSettingsContractArgs.builder()
.oAuth2(OAuth2AuthenticationSettingsContractArgs.builder()
.authorizationServerId("authorizationServerId2283")
.scope("oauth2scope2580")
.build())
.build())
.description("apidescription5200")
.displayName("apiname1463")
.path("newapiPath")
.protocols(
"https",
"http")
.resourceGroupName("rg1")
.serviceName("apimService1")
.serviceUrl("http://newechoapi.cloudapp.net/api")
.subscriptionKeyParameterNames(SubscriptionKeyParameterNamesContractArgs.builder()
.header("header4520")
.query("query3037")
.build())
.build());
}
}
resources:
api:
type: azure-native:apimanagement:Api
properties:
apiId: tempgroup
authenticationSettings:
oAuth2:
authorizationServerId: authorizationServerId2283
scope: oauth2scope2580
description: apidescription5200
displayName: apiname1463
path: newapiPath
protocols:
- https
- http
resourceGroupName: rg1
serviceName: apimService1
serviceUrl: http://newechoapi.cloudapp.net/api
subscriptionKeyParameterNames:
header: header4520
query: query3037
The path property sets the API’s public URL segment, appended to the API Management gateway URL. The serviceUrl points to your backend service. The authenticationSettings block configures OAuth2, referencing an authorization server by ID and defining the required scope. The protocols array determines whether the API accepts HTTP, HTTPS, or both.
Import an API from an OpenAPI specification
Teams often import APIs from existing OpenAPI specifications rather than defining operations manually, preserving the API contract defined in the spec.
import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";
const api = new azure_native.apimanagement.Api("api", {
apiId: "petstore",
format: azure_native.apimanagement.ContentFormat.Openapi_link,
path: "petstore",
resourceGroupName: "rg1",
serviceName: "apimService1",
value: "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml",
});
import pulumi
import pulumi_azure_native as azure_native
api = azure_native.apimanagement.Api("api",
api_id="petstore",
format=azure_native.apimanagement.ContentFormat.OPENAPI_LINK,
path="petstore",
resource_group_name="rg1",
service_name="apimService1",
value="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml")
package main
import (
apimanagement "github.com/pulumi/pulumi-azure-native-sdk/apimanagement/v3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apimanagement.NewApi(ctx, "api", &apimanagement.ApiArgs{
ApiId: pulumi.String("petstore"),
Format: pulumi.String(apimanagement.ContentFormat_Openapi_Link),
Path: pulumi.String("petstore"),
ResourceGroupName: pulumi.String("rg1"),
ServiceName: pulumi.String("apimService1"),
Value: pulumi.String("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var api = new AzureNative.ApiManagement.Api("api", new()
{
ApiId = "petstore",
Format = AzureNative.ApiManagement.ContentFormat.Openapi_link,
Path = "petstore",
ResourceGroupName = "rg1",
ServiceName = "apimService1",
Value = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.apimanagement.Api;
import com.pulumi.azurenative.apimanagement.ApiArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var api = new Api("api", ApiArgs.builder()
.apiId("petstore")
.format("openapi-link")
.path("petstore")
.resourceGroupName("rg1")
.serviceName("apimService1")
.value("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml")
.build());
}
}
resources:
api:
type: azure-native:apimanagement:Api
properties:
apiId: petstore
format: openapi-link
path: petstore
resourceGroupName: rg1
serviceName: apimService1
value: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
The format property tells API Management to import from an OpenAPI specification. The value property provides the URL to the OpenAPI YAML or JSON file. API Management reads the specification, creates operations automatically, and maps them to the backend service. The path property sets where the API appears in the gateway URL structure.
Clone an existing API with all operations
When creating variations of an API, you can clone an existing API to copy its operations and configuration.
import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";
const api = new azure_native.apimanagement.Api("api", {
apiId: "echo-api2",
description: "Copy of Existing Echo Api including Operations.",
displayName: "Echo API2",
isCurrent: true,
path: "echo2",
protocols: [
azure_native.apimanagement.Protocol.Http,
azure_native.apimanagement.Protocol.Https,
],
resourceGroupName: "rg1",
serviceName: "apimService1",
serviceUrl: "http://echoapi.cloudapp.net/api",
sourceApiId: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/58a4aeac497000007d040001",
subscriptionRequired: true,
});
import pulumi
import pulumi_azure_native as azure_native
api = azure_native.apimanagement.Api("api",
api_id="echo-api2",
description="Copy of Existing Echo Api including Operations.",
display_name="Echo API2",
is_current=True,
path="echo2",
protocols=[
azure_native.apimanagement.Protocol.HTTP,
azure_native.apimanagement.Protocol.HTTPS,
],
resource_group_name="rg1",
service_name="apimService1",
service_url="http://echoapi.cloudapp.net/api",
source_api_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/58a4aeac497000007d040001",
subscription_required=True)
package main
import (
apimanagement "github.com/pulumi/pulumi-azure-native-sdk/apimanagement/v3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apimanagement.NewApi(ctx, "api", &apimanagement.ApiArgs{
ApiId: pulumi.String("echo-api2"),
Description: pulumi.String("Copy of Existing Echo Api including Operations."),
DisplayName: pulumi.String("Echo API2"),
IsCurrent: pulumi.Bool(true),
Path: pulumi.String("echo2"),
Protocols: pulumi.StringArray{
pulumi.String(apimanagement.ProtocolHttp),
pulumi.String(apimanagement.ProtocolHttps),
},
ResourceGroupName: pulumi.String("rg1"),
ServiceName: pulumi.String("apimService1"),
ServiceUrl: pulumi.String("http://echoapi.cloudapp.net/api"),
SourceApiId: pulumi.String("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/58a4aeac497000007d040001"),
SubscriptionRequired: pulumi.Bool(true),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var api = new AzureNative.ApiManagement.Api("api", new()
{
ApiId = "echo-api2",
Description = "Copy of Existing Echo Api including Operations.",
DisplayName = "Echo API2",
IsCurrent = true,
Path = "echo2",
Protocols = new[]
{
AzureNative.ApiManagement.Protocol.Http,
AzureNative.ApiManagement.Protocol.Https,
},
ResourceGroupName = "rg1",
ServiceName = "apimService1",
ServiceUrl = "http://echoapi.cloudapp.net/api",
SourceApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/58a4aeac497000007d040001",
SubscriptionRequired = true,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.apimanagement.Api;
import com.pulumi.azurenative.apimanagement.ApiArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var api = new Api("api", ApiArgs.builder()
.apiId("echo-api2")
.description("Copy of Existing Echo Api including Operations.")
.displayName("Echo API2")
.isCurrent(true)
.path("echo2")
.protocols(
"http",
"https")
.resourceGroupName("rg1")
.serviceName("apimService1")
.serviceUrl("http://echoapi.cloudapp.net/api")
.sourceApiId("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/58a4aeac497000007d040001")
.subscriptionRequired(true)
.build());
}
}
resources:
api:
type: azure-native:apimanagement:Api
properties:
apiId: echo-api2
description: Copy of Existing Echo Api including Operations.
displayName: Echo API2
isCurrent: true
path: echo2
protocols:
- http
- https
resourceGroupName: rg1
serviceName: apimService1
serviceUrl: http://echoapi.cloudapp.net/api
sourceApiId: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/58a4aeac497000007d040001
subscriptionRequired: true
The sourceApiId references the full resource ID of the API to clone. API Management copies all operations, policies, and settings from the source API to the new API. The isCurrent property marks this as the active version. The path and displayName distinguish the clone from the original.
Create a new API version from an existing API
API versioning allows you to maintain multiple versions of an API simultaneously, each with its own operations and configuration.
import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";
const api = new azure_native.apimanagement.Api("api", {
apiId: "echoapiv3",
apiVersion: "v4",
apiVersionSetId: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458",
description: "Create Echo API into a new Version using Existing Version Set and Copy all Operations.",
displayName: "Echo API2",
isCurrent: true,
path: "echo2",
protocols: [
azure_native.apimanagement.Protocol.Http,
azure_native.apimanagement.Protocol.Https,
],
resourceGroupName: "rg1",
serviceName: "apimService1",
serviceUrl: "http://echoapi.cloudapp.net/api",
sourceApiId: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoPath",
subscriptionRequired: true,
});
import pulumi
import pulumi_azure_native as azure_native
api = azure_native.apimanagement.Api("api",
api_id="echoapiv3",
api_version="v4",
api_version_set_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458",
description="Create Echo API into a new Version using Existing Version Set and Copy all Operations.",
display_name="Echo API2",
is_current=True,
path="echo2",
protocols=[
azure_native.apimanagement.Protocol.HTTP,
azure_native.apimanagement.Protocol.HTTPS,
],
resource_group_name="rg1",
service_name="apimService1",
service_url="http://echoapi.cloudapp.net/api",
source_api_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoPath",
subscription_required=True)
package main
import (
apimanagement "github.com/pulumi/pulumi-azure-native-sdk/apimanagement/v3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apimanagement.NewApi(ctx, "api", &apimanagement.ApiArgs{
ApiId: pulumi.String("echoapiv3"),
ApiVersion: pulumi.String("v4"),
ApiVersionSetId: pulumi.String("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458"),
Description: pulumi.String("Create Echo API into a new Version using Existing Version Set and Copy all Operations."),
DisplayName: pulumi.String("Echo API2"),
IsCurrent: pulumi.Bool(true),
Path: pulumi.String("echo2"),
Protocols: pulumi.StringArray{
pulumi.String(apimanagement.ProtocolHttp),
pulumi.String(apimanagement.ProtocolHttps),
},
ResourceGroupName: pulumi.String("rg1"),
ServiceName: pulumi.String("apimService1"),
ServiceUrl: pulumi.String("http://echoapi.cloudapp.net/api"),
SourceApiId: pulumi.String("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoPath"),
SubscriptionRequired: pulumi.Bool(true),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var api = new AzureNative.ApiManagement.Api("api", new()
{
ApiId = "echoapiv3",
ApiVersion = "v4",
ApiVersionSetId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458",
Description = "Create Echo API into a new Version using Existing Version Set and Copy all Operations.",
DisplayName = "Echo API2",
IsCurrent = true,
Path = "echo2",
Protocols = new[]
{
AzureNative.ApiManagement.Protocol.Http,
AzureNative.ApiManagement.Protocol.Https,
},
ResourceGroupName = "rg1",
ServiceName = "apimService1",
ServiceUrl = "http://echoapi.cloudapp.net/api",
SourceApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoPath",
SubscriptionRequired = true,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.apimanagement.Api;
import com.pulumi.azurenative.apimanagement.ApiArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var api = new Api("api", ApiArgs.builder()
.apiId("echoapiv3")
.apiVersion("v4")
.apiVersionSetId("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458")
.description("Create Echo API into a new Version using Existing Version Set and Copy all Operations.")
.displayName("Echo API2")
.isCurrent(true)
.path("echo2")
.protocols(
"http",
"https")
.resourceGroupName("rg1")
.serviceName("apimService1")
.serviceUrl("http://echoapi.cloudapp.net/api")
.sourceApiId("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoPath")
.subscriptionRequired(true)
.build());
}
}
resources:
api:
type: azure-native:apimanagement:Api
properties:
apiId: echoapiv3
apiVersion: v4
apiVersionSetId: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458
description: Create Echo API into a new Version using Existing Version Set and Copy all Operations.
displayName: Echo API2
isCurrent: true
path: echo2
protocols:
- http
- https
resourceGroupName: rg1
serviceName: apimService1
serviceUrl: http://echoapi.cloudapp.net/api
sourceApiId: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoPath
subscriptionRequired: true
The apiVersion property sets the version identifier (e.g., “v4”). The apiVersionSetId references a version set that groups related API versions together. The sourceApiId copies operations from an existing API. The isCurrent property determines whether this version is the default when clients don’t specify a version.
Create an API revision for testing changes
API revisions let you test changes to an API without affecting the current version, using the same path but different backend URLs or configurations.
import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";
const api = new azure_native.apimanagement.Api("api", {
apiId: "echo-api;rev=3",
apiRevisionDescription: "Creating a Revision of an existing API",
path: "echo",
resourceGroupName: "rg1",
serviceName: "apimService1",
serviceUrl: "http://echoapi.cloudapp.net/apiv3",
sourceApiId: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api",
});
import pulumi
import pulumi_azure_native as azure_native
api = azure_native.apimanagement.Api("api",
api_id="echo-api;rev=3",
api_revision_description="Creating a Revision of an existing API",
path="echo",
resource_group_name="rg1",
service_name="apimService1",
service_url="http://echoapi.cloudapp.net/apiv3",
source_api_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api")
package main
import (
apimanagement "github.com/pulumi/pulumi-azure-native-sdk/apimanagement/v3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apimanagement.NewApi(ctx, "api", &apimanagement.ApiArgs{
ApiId: pulumi.String("echo-api;rev=3"),
ApiRevisionDescription: pulumi.String("Creating a Revision of an existing API"),
Path: pulumi.String("echo"),
ResourceGroupName: pulumi.String("rg1"),
ServiceName: pulumi.String("apimService1"),
ServiceUrl: pulumi.String("http://echoapi.cloudapp.net/apiv3"),
SourceApiId: pulumi.String("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var api = new AzureNative.ApiManagement.Api("api", new()
{
ApiId = "echo-api;rev=3",
ApiRevisionDescription = "Creating a Revision of an existing API",
Path = "echo",
ResourceGroupName = "rg1",
ServiceName = "apimService1",
ServiceUrl = "http://echoapi.cloudapp.net/apiv3",
SourceApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.apimanagement.Api;
import com.pulumi.azurenative.apimanagement.ApiArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var api = new Api("api", ApiArgs.builder()
.apiId("echo-api;rev=3")
.apiRevisionDescription("Creating a Revision of an existing API")
.path("echo")
.resourceGroupName("rg1")
.serviceName("apimService1")
.serviceUrl("http://echoapi.cloudapp.net/apiv3")
.sourceApiId("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api")
.build());
}
}
resources:
api:
type: azure-native:apimanagement:Api
properties:
apiId: echo-api;rev=3
apiRevisionDescription: Creating a Revision of an existing API
path: echo
resourceGroupName: rg1
serviceName: apimService1
serviceUrl: http://echoapi.cloudapp.net/apiv3
sourceApiId: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api
The apiId uses semicolon syntax (echo-api;rev=3) to denote the revision number. The apiRevisionDescription documents what changed in this revision. The sourceApiId copies the base API’s operations. The serviceUrl can point to a different backend for testing. Revisions remain non-current until explicitly promoted.
Expose a GraphQL API endpoint
GraphQL APIs require different handling than REST APIs, with API Management proxying GraphQL endpoints while applying policies and authentication.
import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";
const api = new azure_native.apimanagement.Api("api", {
apiId: "tempgroup",
apiType: azure_native.apimanagement.ApiType.Graphql,
description: "apidescription5200",
displayName: "apiname1463",
path: "graphql-api",
protocols: [
azure_native.apimanagement.Protocol.Http,
azure_native.apimanagement.Protocol.Https,
],
resourceGroupName: "rg1",
serviceName: "apimService1",
serviceUrl: "https://api.spacex.land/graphql",
});
import pulumi
import pulumi_azure_native as azure_native
api = azure_native.apimanagement.Api("api",
api_id="tempgroup",
api_type=azure_native.apimanagement.ApiType.GRAPHQL,
description="apidescription5200",
display_name="apiname1463",
path="graphql-api",
protocols=[
azure_native.apimanagement.Protocol.HTTP,
azure_native.apimanagement.Protocol.HTTPS,
],
resource_group_name="rg1",
service_name="apimService1",
service_url="https://api.spacex.land/graphql")
package main
import (
apimanagement "github.com/pulumi/pulumi-azure-native-sdk/apimanagement/v3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apimanagement.NewApi(ctx, "api", &apimanagement.ApiArgs{
ApiId: pulumi.String("tempgroup"),
ApiType: pulumi.String(apimanagement.ApiTypeGraphql),
Description: pulumi.String("apidescription5200"),
DisplayName: pulumi.String("apiname1463"),
Path: pulumi.String("graphql-api"),
Protocols: pulumi.StringArray{
pulumi.String(apimanagement.ProtocolHttp),
pulumi.String(apimanagement.ProtocolHttps),
},
ResourceGroupName: pulumi.String("rg1"),
ServiceName: pulumi.String("apimService1"),
ServiceUrl: pulumi.String("https://api.spacex.land/graphql"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var api = new AzureNative.ApiManagement.Api("api", new()
{
ApiId = "tempgroup",
ApiType = AzureNative.ApiManagement.ApiType.Graphql,
Description = "apidescription5200",
DisplayName = "apiname1463",
Path = "graphql-api",
Protocols = new[]
{
AzureNative.ApiManagement.Protocol.Http,
AzureNative.ApiManagement.Protocol.Https,
},
ResourceGroupName = "rg1",
ServiceName = "apimService1",
ServiceUrl = "https://api.spacex.land/graphql",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.apimanagement.Api;
import com.pulumi.azurenative.apimanagement.ApiArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var api = new Api("api", ApiArgs.builder()
.apiId("tempgroup")
.apiType("graphql")
.description("apidescription5200")
.displayName("apiname1463")
.path("graphql-api")
.protocols(
"http",
"https")
.resourceGroupName("rg1")
.serviceName("apimService1")
.serviceUrl("https://api.spacex.land/graphql")
.build());
}
}
resources:
api:
type: azure-native:apimanagement:Api
properties:
apiId: tempgroup
apiType: graphql
description: apidescription5200
displayName: apiname1463
path: graphql-api
protocols:
- http
- https
resourceGroupName: rg1
serviceName: apimService1
serviceUrl: https://api.spacex.land/graphql
The apiType property set to “graphql” tells API Management to handle GraphQL-specific request patterns. The serviceUrl points to your GraphQL backend. API Management preserves GraphQL query structure while applying rate limiting, authentication, and other policies. The protocols array typically includes both HTTP and HTTPS for GraphQL endpoints.
Beyond these examples
These snippets focus on specific API-level features: API creation with OAuth2 and OpenID Connect authentication, API import from OpenAPI and other specifications, API versioning and revision management, and protocol-specific APIs. They’re intentionally minimal rather than full API gateway configurations.
The examples reference pre-existing infrastructure such as API Management service instances, resource groups, OAuth2 authorization servers or OpenID Connect providers, backend services, and API version sets for versioned APIs. They focus on configuring the API rather than provisioning the surrounding infrastructure.
To keep things focused, common API patterns are omitted, including:
- Subscription key configuration and custom parameter names
- Contact information and license details
- Terms of service URLs
- API-level policies and transformations
- Product associations and visibility settings
- Backend certificate validation and mutual TLS
These omissions are intentional: the goal is to illustrate how each API feature is wired, not provide drop-in API gateway modules. See the API Management Api resource reference for all available configuration options.
Let's configure Azure API Management APIs
Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.
Try Pulumi Cloud for FREEFrequently Asked Questions
API Import & Creation
swagger-link-json, openapi-link, wsdl-link, wadl-link-json, grpc-link, or odata-link formats. Set the format property and provide the specification URL in value.graphql), gRPC (grpc), OData (odata), WebSocket (websocket), and SOAP (soap). Specify the type using the apiType property.format to openapi-link and provide the OpenAPI specification URL in the value property. The API will be created with operations defined in the specification.wsdlSelector property with wsdlEndpointName and wsdlServiceName to specify which endpoint and service from the WSDL document to import.Versioning & Revisions
apiVersion and apiVersionSetId). Revisions are iterations of the same API version, specified with ;rev=n in the apiId property.;rev=n in the apiId (e.g., echo-api;rev=3), set sourceApiId to the original API’s resource identifier, and optionally provide an apiRevisionDescription.sourceApiId property to the resource identifier of the API you want to clone. All operations will be copied to the new API.isCurrent property indicates whether an API revision is the current active revision. Set it to true to make a revision the current one.SOAP APIs
format to wsdl-link, soapApiType to soap, and configure wsdlSelector with the WSDL endpoint and service names. This preserves the original SOAP protocol.format set to wsdl-link with wsdlSelector configured, but omit the soapApiType property. The API will be converted to REST by default.Authentication & Security
authenticationSettings.oAuth2 with authorizationServerId and scope properties to configure OAuth2 authentication.authenticationSettings.oAuth2AuthenticationSettings as an array to configure multiple OAuth2 servers, each with its own authorizationServerId and scope.authenticationSettings.openid with openidProviderId and bearerTokenSendingMethods to configure OpenID Connect authentication.Advanced Configuration
ws (WebSocket) and wss (WebSocket Secure) protocols. Specify these in the protocols array.template (default) to convert them to path template parameters, or query to keep them as query parameters.Using a different cloud?
Explore integration guides for other cloud providers: