Skip to content

Commit

Permalink
Add deprecation warning for microsoftGraph builtin extension (#15149)
Browse files Browse the repository at this point in the history
Adding a deprecation warning for `microsoftGraph` builtin extension.
Users should use dynamic types instead.


###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/15149)
  • Loading branch information
jason-dou authored Sep 27, 2024
1 parent 02f6ec3 commit 1988aa8
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public static IEnumerable<object[]> ExtensionsConfig_SupportForConfigManagedExte
emptyDiagnostics };
yield return new object[] {
"microsoftGraph",
true,
emptyDiagnostics };
false,
new (string, DiagnosticLevel, string)[] {
("BCP407", DiagnosticLevel.Warning, "Extension \"microsoftGraph\" is deprecated. Use dynamic types instead. See https://aka.ms/graphBicepDynamicTypes" ) } };
yield return new object[] {
"az",
true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"experimentalFeaturesEnabled": {
"extensibility": true
},
"extensions": {
"microsoftGraphV1_0": "br:mcr.microsoft.com/bicep/extensions/microsoftgraph/v1.0:0.1.8-preview",
"microsoftGraphBeta": "br:mcr.microsoft.com/bicep/extensions/microsoftgraph/beta:0.1.8-preview"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
extension microsoftGraph as graph
extension microsoftGraphV1_0
extension microsoftGraphBeta

param appRoleId string = 'bc76c90e-eb7f-4a29-943b-49e88762d09d'
param scopeId string = 'f761933c-643b-424f-a169-f9313d23a913'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extension microsoftGraph
extension microsoftGraphBeta

resource resourceApp 'Microsoft.Graph/applications@beta' existing = {
uniqueName: 'resourceApp'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
"_generator": {
"name": "bicep",
"version": "dev",
"templateHash": "10094365870369225747"
"templateHash": "14301681087671152959"
}
},
"imports": {
"microsoftGraph": {
"MicrosoftGraphBeta": {
"provider": "MicrosoftGraph",
"version": "1.0.0"
"version": "0.1.8-preview"
}
},
"resources": {
"resourceApp": {
"existing": true,
"import": "microsoftGraph",
"import": "MicrosoftGraphBeta",
"type": "Microsoft.Graph/applications@beta",
"properties": {
"uniqueName": "resourceApp"
}
},
"group": {
"existing": true,
"import": "microsoftGraph",
"import": "MicrosoftGraphBeta",
"type": "Microsoft.Graph/applications@beta",
"properties": {
"uniqueName": "myGroup"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"_generator": {
"name": "bicep",
"version": "dev",
"templateHash": "13653571511506928892"
"templateHash": "15609368468620239727"
}
},
"parameters": {
Expand All @@ -24,14 +24,18 @@
}
},
"imports": {
"graph": {
"MicrosoftGraph": {
"provider": "MicrosoftGraph",
"version": "1.0.0"
"version": "0.1.8-preview"
},
"MicrosoftGraphBeta": {
"provider": "MicrosoftGraph",
"version": "0.1.8-preview"
}
},
"resources": {
"appV1::myTestFIC": {
"import": "graph",
"import": "MicrosoftGraph",
"type": "Microsoft.Graph/applications/federatedIdentityCredentials@v1.0",
"properties": {
"name": "[format('{0}/mytestfic', reference('appV1').uniqueName)]",
Expand All @@ -47,7 +51,7 @@
]
},
"resourceApp": {
"import": "graph",
"import": "MicrosoftGraphBeta",
"type": "Microsoft.Graph/applications@beta",
"properties": {
"uniqueName": "resourceApp",
Expand Down Expand Up @@ -80,7 +84,7 @@
}
},
"resourceSp": {
"import": "graph",
"import": "MicrosoftGraphBeta",
"type": "Microsoft.Graph/servicePrincipals@beta",
"properties": {
"appId": "[reference('resourceApp').appId]"
Expand All @@ -90,15 +94,15 @@
]
},
"clientApp": {
"import": "graph",
"import": "MicrosoftGraphBeta",
"type": "Microsoft.Graph/applications@beta",
"properties": {
"uniqueName": "clientApp",
"displayName": "My Client App"
}
},
"clientSp": {
"import": "graph",
"import": "MicrosoftGraphBeta",
"type": "Microsoft.Graph/servicePrincipals@beta",
"properties": {
"appId": "[reference('clientApp').appId]"
Expand All @@ -108,7 +112,7 @@
]
},
"permissionGrant": {
"import": "graph",
"import": "MicrosoftGraphBeta",
"type": "Microsoft.Graph/oauth2PermissionGrants@beta",
"properties": {
"clientId": "[reference('clientSp').id]",
Expand All @@ -122,7 +126,7 @@
]
},
"appRoleAssignedTo": {
"import": "graph",
"import": "MicrosoftGraphBeta",
"type": "Microsoft.Graph/appRoleAssignedTo@beta",
"properties": {
"appRoleId": "[parameters('appRoleId')]",
Expand All @@ -135,7 +139,7 @@
]
},
"group": {
"import": "graph",
"import": "MicrosoftGraphBeta",
"type": "Microsoft.Graph/groups@beta",
"properties": {
"uniqueName": "myGroup",
Expand All @@ -155,12 +159,12 @@
]
},
"appV1": {
"import": "graph",
"import": "MicrosoftGraph",
"type": "Microsoft.Graph/applications@v1.0",
"properties": {
"displayName": "TestAppV1",
"uniqueName": "testAppV1"
}
}
}
}
}
4 changes: 4 additions & 0 deletions src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,10 @@ public Diagnostic MoreThanOneExtendsDeclarationSpecified() => CoreError(
public Diagnostic ExtendsNotSupported() => CoreError(
"BCP406",
$"The \"{LanguageConstants.ExtendsKeyword}\" keyword is not supported");

public Diagnostic MicrosoftGraphBuiltinDeprecatedSoon() => CoreWarning(
"BCP407",
$"Extension \"microsoftGraph\" is deprecated. Use dynamic types instead. See https://aka.ms/graphBicepDynamicTypes");
}

public static DiagnosticBuilderInternal ForPosition(TextSpan span)
Expand Down
5 changes: 5 additions & 0 deletions src/Bicep.Core/TypeSystem/TypeAssignmentVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,11 @@ namespaceType.ConfigurationType is not null &&
}
}
if (LanguageConstants.IdentifierComparer.Equals(namespaceType.Name, MicrosoftGraphNamespaceType.BuiltInName))
{
diagnostics.Write(syntax, x => x.MicrosoftGraphBuiltinDeprecatedSoon());
}
return namespaceType;
});

Expand Down

0 comments on commit 1988aa8

Please sign in to comment.