Skip to content

Commit 1703c05

Browse files
Fix listing functions on sovereign clouds (#4112)
1 parent 8216e2b commit 1703c05

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

src/FunctionAppResolver.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,29 @@ export class FunctionAppResolver implements AppResourceResolver {
4848
}
4949

5050
async function getSites20231201(context: IActionContext, subContext: ISubscriptionContext): Promise<(Site & { properties?: { functionAppConfig: FunctionAppConfig } })[]> {
51-
const headers = createHttpHeaders({
52-
'Content-Type': 'application/json',
53-
});
51+
try {
52+
const headers = createHttpHeaders({
53+
'Content-Type': 'application/json',
54+
});
55+
56+
const armEndpoint = ensureEndingSlash(subContext.environment.resourceManagerEndpointUrl);
57+
58+
// we need the new api-version to get the functionAppConfig
59+
const options: AzExtRequestPrepareOptions = {
60+
url: `${armEndpoint}subscriptions/${subContext.subscriptionId}/providers/Microsoft.Web/sites?api-version=2023-12-01`,
61+
method: 'GET',
62+
headers
63+
};
5464

55-
// we need the new api-version to get the functionAppConfig
56-
const options: AzExtRequestPrepareOptions = {
57-
url: `https://management.azure.com/subscriptions/${subContext.subscriptionId}/providers/Microsoft.Web/sites?api-version=2023-12-01`,
58-
method: 'GET',
59-
headers
60-
};
65+
const client = await createGenericClient(context, subContext);
66+
const result = await client.sendRequest(createPipelineRequest(options)) as AzExtPipelineResponse;
6167

62-
const client = await createGenericClient(context, subContext);
63-
const result = await client.sendRequest(createPipelineRequest(options)) as AzExtPipelineResponse;
64-
return (result.parsedBody as { value: unknown }).value as (Site & { properties?: { functionAppConfig: FunctionAppConfig } })[];
68+
return (result.parsedBody as { value: unknown }).value as (Site & { properties?: { functionAppConfig: FunctionAppConfig } })[] ?? [];
69+
} catch (_error) {
70+
return [];
71+
}
6572
}
6673

74+
function ensureEndingSlash(url: string): string {
75+
return url.endsWith('/') ? url : `${url}/`;
76+
}

0 commit comments

Comments
 (0)