Skip to content

Commit a082987

Browse files
xiangyan99xiafu-msftlmazuelkristapraticoZim Kalinowski
authored
get master (#11193)
* [DataLake][Bug]Upload is not working with umask and permissions (#10845) * Add force generation to SwaggerToSdk (#10933) * [formrecognizer] edits to docstrings (#11003) * edits to docstrings * correct date * updating setup template (#11022) * [formrecognizer] handle unsupervised pages better with service bug (#11017) * handle unsupervised pages better * python 2 oops * Increment package version after release of azure_ai_formrecognizer (#11026) * add regular endpoint in new env variable (#11031) * Update Ubuntu VM Image to 18.04 (#11032) * updating the VM image, need to update the recording as well. * update release * fixing merge error (#11039) * Fixing compute test (#11036) * trigger test * Packaging update of azure-mgmt-compute * fix test * fix * fix duplicated comment Co-authored-by: Azure SDK Bot <aspysdk2@microsoft.com> * Servicebus - Track2 - Remove timeout from Send (#11002) * With retry options available, send should no longer require its own timeout. Removes the parameter from sync and async clients, adds a note to changelog about the delta. * rename SearchIndexClient -> SearchClient (#10964) * Implementation for Datasources operations (#11012) * Initial Commit * lint + mypy * tests * recordings update * Apply suggestions from code review * typo * remove datasource * lint * rename to get_datasources Co-authored-by: Bryan Van de Ven <bryan@bokeh.org> * [ServiceBus] Update for readme and sample (#11047) * tweak sample code * update according to comment * add aad sample in readme * Update sdk/servicebus/azure-servicebus/README.md Co-Authored-By: KieranBrantnerMagee <kibrantn@microsoft.com> Co-authored-by: KieranBrantnerMagee <kibrantn@microsoft.com> * Fix pip link in azure-keyvault-secrets readme (#11056) * fixed alternative document input samples (#11078) * Add sync/async samples to demonstrate consuming from a number of sessions at one time. (#11001) * Add sync/async samples to demonstrate consuming from a number of sessions at one time. * Add informational message to session pool samples regarding the exit condition and how it manifests. * [ServiceBus] Settle non-deferred message through receiver link (#10800) * settle non-deferred message through receiver link except dead_letter * revert dead-letter back to t1 as well * improve settlement and put is_deferred_letter into kwargs * add test * update according to comment * fix a bug in dead_letter through receiver_link * Search README issues (#11082) * fix for azure.search.documents change * indentation, naming * SearchIndexClient -> SearchClient * Update README.md (#11084) * [ServiceBus] Remove exception from __init__.py (#11080) * remove exception from __init__.py * update changelog, fix some docstring and sample error * Pin astroid to 2.3.3 to fix pylint failure (#11088) * Lint error in cosmos (#11092) * Fix TYPING cycles if TYPE_CHECKING manually forced (#10799) * Improve mypy typing for azure core (#10653) * first commit * more changes * few changes * lint * comments * more changes * fix test * lint * mypy * comments * changes * async polling method * async * Accept authority option with or without scheme (#11050) * Split Search Service Client (#11090) * split datasources client * split skillsets client * split synonym maps client * split indexes client * cleanup * [text analytics] Add how to get json response to sample (#11102) * ARM default whitelist headers (#10940) * ARM default whitelist headers * ChangeLog * Typo * Syntax error * Update sdk/core/azure-mgmt-core/CHANGELOG.md Co-Authored-By: Jiashuo Li <jiasli@microsoft.com> * More headers Co-authored-by: Jiashuo Li <jiasli@microsoft.com> * update version (#11106) * Return pageable for Search list_indexes (#11125) * Adjust README with comments from the per-release doc review. (#11110) * Adjust README with comments from the per-release doc review. * Make additional breadcrumb to samples higher in the page, duplication is OKd (and even recommended) in this case. * Removed spurious FIFO reference. * Added a note about preview vs. existing docs, with breadcrumb to existing libs. * Make 0.50 doc links more specific. * [Event Hubs] add enqueueTime to Process span links (#10932) * remove formatter in samples/readme.md to prevent preview samples being published (#10884) * [DataLake]Update ChangeLog (#11133) * Add capability to send multiple events in one Send() call. (#11093) * Add the ability for send to take a list of messages, failing if they don't fit in a single batch to maintain idempotency. * Adds tests for multisend. * Puts details of multisend into the changelog. * Adjust docstring type definition for send() async. * Make test more targeted (256KB) for too-large validation. * Create batch helper to create from list. * Adjust docstrings to point to proper exception location instead of under common. * Fix failing unit test expecting the old send error type. * Remove test segments that will likely never be readded (queue message) and make docstring type inputs for send() more precise. * Set time out to 90 mins for regression test (#11105) * Autorest check to run tests in autorestv3 branch for core (#11131) * Autorest CI changes to use autorestv3 * Add DeleteAfter tag to Search test resource groups (#11136) * add DeleteAfter tag to RG * update recordings * Increment version for storage releases (#11138) * Increment package version after release of azure_storage_blob * Increment package version after release of azure_storage_file_datalake * [Event Hubs] `EventHubProducerClient.send_batch` accepts a list of EventData (#11079) * add ServiceDirectory to usage of remove-test-resources.yml (#11117) * resume subscriptions test (#11111) * resume subscriptions test * recording subscriptions * Adding test for signalr (#11146) * generated signalr test * generated recording * Packaging update of azure-mgmt-signalr Co-authored-by: Azure SDK Bot <aspysdk2@microsoft.com> * update live tests yml + add form (#11139) * [Service Bus] Exception Handling review (#11060) * [form recognizer] add repr (#11150) * [ServiceBus] Support for scheduling and cancellation (#11095) * make schedule a property on the message * make send api public * schedule and cancellation * remove iterable type hint and docstring * update implementation * update comment * update docs * Update sdk/servicebus/azure-servicebus/CHANGELOG.md Co-authored-by: KieranBrantnerMagee <kibrantn@microsoft.com> Co-authored-by: KieranBrantnerMagee <kibrantn@microsoft.com> * identity_vscode_credential (#10840) * identity_win_vscode_credential Co-authored-by: Charles Lowell <chlowe@microsoft.com> * Sync eng/common directory with azure-sdk-tools repository (#11007) * ChangeLog generics for autorest v5 (#10885) * ChangeLog generics for autorest v5 * Update changelog_generics.md * [Event Hubs] Add params in stress test command line for receive batch and send list (#11161) * Storageache cjf (#11122) * Update from master * release azure-mgmt-storagecache * Update CHANGELOG.md * Packaging update of azure-mgmt-storagecache Co-authored-by: SDK Automation <sdkautomation@microsoft.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: Azure SDK Bot <aspysdk2@microsoft.com> * added AzureKeyCredential link to readme (#11089) * Fix core auth (#11177) * [Azure-Core]Auth Header missing when token credential is not expired * Fix mypy * Test we put the header even if we didn't tech a new token Co-authored-by: xiafu <xiafu@microsoft.com> * [formrecognizer] increase test coverage (#11096) * working on more tests * add multipage tests for custom form and training * adding multipage tests * fix * add tests for bad input into custom analyze * remove test dependency on storage * update tests.yml * fix for custom analyze url unlabeled tests * update changelog * review feedback * pushing a commit to reset CI * Release edits for Search (#11178) * fix README typo * Getting started section order * add first search request subsection * update CHANGELOG * update readme with note about service version support (#11180) * [Event Hubs] Fix a bug that sets owner level 0 (#11172) * [ServiceBus] Docstring and Changelog adjustment (#11166) * Identity use pbyte (#11173) * identity_vscode_cred_format * EnvironmentCredential correctly initializes UsernamePasswordCredential (#11127) * User authentication API for applications (#10612) * [Event Hubs] Version/Docs adjustment for 5.1.0 (#11179) * [form recognizer] Add some stuff that .net has to our samples (#11187) * re-enable schedule tests in session (#11184) * add helpers for search fields (#11164) * add helpers for search fields * pylint * fix annotation * Define match conditions for CreateOrUpdate and Delete operations (#11116) * sync * async * lint * Update sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py * tests fix * use match conditiond * error map * fix test * lint * comments * test_utils * Update sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py * Update sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py Co-authored-by: Johan Stenberg (MSFT) <johan.stenberg@microsoft.com> * Update sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py * Revert "Update sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py" This reverts commit b0ca117. * fix * more changes Co-authored-by: Johan Stenberg (MSFT) <johan.stenberg@microsoft.com> Co-authored-by: Xiaoxi Fu <49707495+xiafu-msft@users.noreply.github.com> Co-authored-by: Laurent Mazuel <laurent.mazuel@gmail.com> Co-authored-by: Krista Pratico <krpratic@microsoft.com> Co-authored-by: Zim Kalinowski <zikalino@microsoft.com> Co-authored-by: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Co-authored-by: Scott Beddall <45376673+scbedd@users.noreply.github.com> Co-authored-by: Azure SDK Bot <aspysdk2@microsoft.com> Co-authored-by: KieranBrantnerMagee <kibrantn@microsoft.com> Co-authored-by: Bryan Van de Ven <bryan@bokeh.org> Co-authored-by: Rakshith Bhyravabhotla <rakshith.bhyravabhotla@gmail.com> Co-authored-by: Adam Ling (MSFT) <47871814+yunhaoling@users.noreply.github.com> Co-authored-by: Charles Lowell <chlowe@microsoft.com> Co-authored-by: praveenkuttappan <55455725+praveenkuttappan@users.noreply.github.com> Co-authored-by: Rakshith Bhyravabhotla <sabhyrav@microsoft.com> Co-authored-by: Jiashuo Li <jiasli@microsoft.com> Co-authored-by: Yijun Xie <48257664+YijunXieMS@users.noreply.github.com> Co-authored-by: Daniel Jurek <djurek@microsoft.com> Co-authored-by: changlong-liu <59815250+changlong-liu@users.noreply.github.com> Co-authored-by: 陈箭飞 <32889038+chenjianfei2017@users.noreply.github.com> Co-authored-by: SDK Automation <sdkautomation@microsoft.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: xiafu <xiafu@microsoft.com> Co-authored-by: Johan Stenberg (MSFT) <johan.stenberg@microsoft.com>
1 parent 6d3ffc5 commit a082987

469 files changed

Lines changed: 56573 additions & 24593 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eng/autorest_req.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ pytest-cov==2.8.1
44
pytest-asyncio==0.10.0; python_version >= '3.5'
55
isodate==0.6.0
66
msrest==0.6.13
7-
aiohttp==3.6.2
7+
aiohttp==3.6.2
8+
wheel

eng/common/TestResources/New-TestResources.ps1

Lines changed: 71 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ param (
6262
[switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID),
6363

6464
[Parameter()]
65-
[switch] $Force
65+
[switch] $Force,
66+
67+
[Parameter()]
68+
[switch] $OutFile
6669
)
6770

6871
# By default stop for any error.
@@ -108,7 +111,8 @@ trap {
108111
}
109112

110113
# Enumerate test resources to deploy. Fail if none found.
111-
$root = [System.IO.Path]::Combine("$PSScriptRoot/../../../sdk", $ServiceDirectory) | Resolve-Path
114+
$repositoryRoot = "$PSScriptRoot/../../.." | Resolve-Path
115+
$root = [System.IO.Path]::Combine($repositoryRoot, "sdk", $ServiceDirectory) | Resolve-Path
112116
$templateFileName = 'test-resources.json'
113117
$templateFiles = @()
114118

@@ -172,19 +176,20 @@ if ($TestApplicationId -and !$TestApplicationOid) {
172176
}
173177
}
174178

179+
180+
# If the ServiceDirectory is an absolute path use the last directory name
181+
# (e.g. D:\foo\bar\ -> bar)
182+
$serviceName = if (Split-Path -IsAbsolute $ServiceDirectory) {
183+
Split-Path -Leaf $ServiceDirectory
184+
} else {
185+
$ServiceDirectory
186+
}
187+
175188
# Format the resource group name based on resource group naming recommendations and limitations.
176189
$resourceGroupName = if ($CI) {
177190
$BaseName = 't' + (New-Guid).ToString('n').Substring(0, 16)
178191
Write-Verbose "Generated base name '$BaseName' for CI build"
179192

180-
# If the ServiceDirectory is an absolute path use the last directory name
181-
# (e.g. D:\foo\bar\ -> bar)
182-
$serviceName = if (Split-Path -IsAbsolute $ServiceDirectory) {
183-
Split-Path -Leaf $ServiceDirectory
184-
} else {
185-
$ServiceDirectory
186-
}
187-
188193
"rg-{0}-$BaseName" -f ($serviceName -replace '[\\\/:]', '-').Substring(0, [Math]::Min($serviceName.Length, 90 - $BaseName.Length - 4)).Trim('-')
189194
} else {
190195
"rg-$BaseName"
@@ -281,12 +286,21 @@ foreach ($templateFile in $templateFiles) {
281286
Write-Verbose "Successfully deployed template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'"
282287
}
283288

284-
if ($deployment.Outputs.Count -and !$CI) {
285-
# Write an extra new line to isolate the environment variables for easy reading.
286-
Log "Persist the following environment variables based on your detected shell ($shell):`n"
289+
$serviceDirectoryPrefix = $serviceName.ToUpperInvariant() + "_"
290+
291+
$context = Get-AzContext;
292+
293+
# Add default values
294+
$deploymentOutputs = @{
295+
"$($serviceDirectoryPrefix)CLIENT_ID" = $TestApplicationId;
296+
"$($serviceDirectoryPrefix)CLIENT_SECRET" = $TestApplicationSecret;
297+
"$($serviceDirectoryPrefix)TENANT_ID" = $context.Tenant.Id;
298+
"$($serviceDirectoryPrefix)SUBSCRIPTION_ID" = $context.Subscription.Id;
299+
"$($serviceDirectoryPrefix)RESOURCE_GROUP" = $resourceGroup.ResourceGroupName;
300+
"$($serviceDirectoryPrefix)LOCATION" = $resourceGroup.Location;
301+
"$($serviceDirectoryPrefix)ENVIRONMENT" = $context.Environment.Name;
287302
}
288303

289-
$deploymentOutputs = @{}
290304
foreach ($key in $deployment.Outputs.Keys) {
291305
$variable = $deployment.Outputs[$key]
292306

@@ -295,23 +309,54 @@ foreach ($templateFile in $templateFiles) {
295309

296310
if ($variable.Type -eq 'String' -or $variable.Type -eq 'SecureString') {
297311
$deploymentOutputs[$key] = $variable.Value
312+
}
313+
}
298314

315+
if ($OutFile)
316+
{
317+
if (!$IsWindows)
318+
{
319+
Write-Host "File option is supported only on Windows"
320+
}
321+
322+
$outputFile = "$templateFile.env"
323+
324+
$environmentText = $deploymentOutputs | ConvertTo-Json;
325+
$bytes = ([System.Text.Encoding]::UTF8).GetBytes($environmentText)
326+
$protectedBytes = [Security.Cryptography.ProtectedData]::Protect($bytes, $null, [Security.Cryptography.DataProtectionScope]::CurrentUser)
327+
328+
Set-Content $outputFile -Value $protectedBytes -AsByteStream -Force
329+
330+
Write-Host "Test environment settings`n $environmentText`nstored into encrypted $outputFile"
331+
}
332+
else
333+
{
334+
335+
if (!$CI) {
336+
# Write an extra new line to isolate the environment variables for easy reading.
337+
Log "Persist the following environment variables based on your detected shell ($shell):`n"
338+
}
339+
340+
foreach ($key in $deploymentOutputs.Keys)
341+
{
342+
$value = $deploymentOutputs[$key]
343+
299344
if ($CI) {
300345
# Treat all ARM template output variables as secrets since "SecureString" variables do not set values.
301346
# In order to mask secrets but set environment variables for any given ARM template, we set variables twice as shown below.
302347
Write-Host "Setting variable '$key': ***"
303-
Write-Host "##vso[task.setvariable variable=_$key;issecret=true;]$($variable.Value)"
304-
Write-Host "##vso[task.setvariable variable=$key;]$($variable.Value)"
348+
Write-Host "##vso[task.setvariable variable=_$key;issecret=true;]$($value)"
349+
Write-Host "##vso[task.setvariable variable=$key;]$($value)"
305350
} else {
306-
Write-Host ($shellExportFormat -f $key, $variable.Value)
351+
Write-Host ($shellExportFormat -f $key, $value)
307352
}
308353
}
309-
}
310354

311-
if ($key) {
312-
# Isolate the environment variables for easy reading.
313-
Write-Host "`n"
314-
$key = $null
355+
if ($key) {
356+
# Isolate the environment variables for easy reading.
357+
Write-Host "`n"
358+
$key = $null
359+
}
315360
}
316361

317362
$postDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1'
@@ -442,6 +487,10 @@ Deployment (CI/CD) build (only Azure Pipelines is currently supported).
442487
.PARAMETER Force
443488
Force creation of resources instead of being prompted.
444489
490+
.PARAMETER OutFile
491+
Save test environment settings into a test-resources.json.env file next to test-resources.json. File is protected via DPAPI. Supported only on windows.
492+
The environment file would be scoped to the current repository directory.
493+
445494
.EXAMPLE
446495
Connect-AzAccount -Subscription "REPLACE_WITH_SUBSCRIPTION_ID"
447496
$testAadApp = New-AzADServicePrincipal -Role Owner -DisplayName 'azure-sdk-live-test-app'

eng/common/TestResources/Remove-TestResources.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ param (
3838
[Parameter(ParameterSetName = 'Default+Provisioner', Mandatory = $true)]
3939
[Parameter(ParameterSetName = 'ResourceGroup+Provisioner', Mandatory = $true)]
4040
[string] $ProvisionerApplicationSecret,
41+
42+
[Parameter()]
43+
[string] $ServiceDirectory,
4144

4245
[Parameter()]
4346
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud')]
@@ -116,6 +119,15 @@ if (!$ResourceGroupName) {
116119
$ResourceGroupName = "rg-$BaseName"
117120
}
118121

122+
if (![string]::IsNullOrWhiteSpace($ServiceDirectory)) {
123+
$root = [System.IO.Path]::Combine("$PSScriptRoot/../../../sdk", $ServiceDirectory) | Resolve-Path
124+
$preRemovalScript = Join-Path -Path $root -ChildPath 'remove-test-resources-pre.ps1'
125+
if (Test-Path $preRemovalScript) {
126+
Log "Invoking pre resource removal script '$preRemovalScript'"
127+
&$preRemovalScript -ResourceGroupName $ResourceGroupName @PSBoundParameters
128+
}
129+
}
130+
119131
Log "Deleting resource group '$ResourceGroupName'"
120132
if (Retry { Remove-AzResourceGroup -Name "$ResourceGroupName" -Force:$Force }) {
121133
Write-Verbose "Successfully deleted resource group '$ResourceGroupName'"
@@ -157,6 +169,10 @@ A service principal ID to provision test resources when a provisioner is specifi
157169
.PARAMETER ProvisionerApplicationSecret
158170
A service principal secret (password) to provision test resources when a provisioner is specified.
159171
172+
.PARAMETER ServiceDirectory
173+
A directory under 'sdk' in the repository root - optionally with subdirectories
174+
specified - in which to discover pre removal script named 'remove-test-resources-pre.json'.
175+
160176
.PARAMETER Environment
161177
Name of the cloud environment. The default is the Azure Public Cloud
162178
('PublicCloud')

eng/common/TestResources/Remove-TestResources.ps1.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,22 @@ Accept pipeline input: False
169169
Accept wildcard characters: False
170170
```
171171
172+
### -ServiceDirectory
173+
A directory under 'sdk' in the repository root - optionally with subdirectories
174+
specified - specified - in which to discover pre removal script named 'remove-test-resources-pre.json'.
175+
176+
```yaml
177+
Type: String
178+
Parameter Sets: (All)
179+
Aliases:
180+
181+
Required: False
182+
Position: Named
183+
Default value: None
184+
Accept pipeline input: False
185+
Accept wildcard characters: False
186+
```
187+
172188
### -Environment
173189
Name of the cloud environment.
174190
The default is the Azure Public Cloud

eng/common/TestResources/remove-test-resources.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# Assumes steps in deploy-test-resources.yml was run previously. Requires
88
# environment variable: AZURE_RESOURCEGROUP_NAME and Az PowerShell module
99

10+
parameters:
11+
ServiceDirectory: ''
12+
1013
steps:
1114
- pwsh: >
1215
eng/common/TestResources/Remove-TestResources.ps1
@@ -15,6 +18,7 @@ steps:
1518
-SubscriptionId '$(azure-subscription-id)'
1619
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id)'
1720
-ProvisionerApplicationSecret '$(aad-azure-sdk-test-client-secret)'
21+
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
1822
-Environment 'AzureCloud'
1923
-Force
2024
-Verbose
@@ -29,6 +33,7 @@ steps:
2933
-SubscriptionId '$(azure-subscription-id-gov)'
3034
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id-gov)'
3135
-ProvisionerApplicationSecret '$(aad-azure-sdk-test-client-secret-gov)'
36+
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
3237
-Environment 'AzureUSGovernment'
3338
-Force
3439
-Verbose
@@ -43,6 +48,7 @@ steps:
4348
-SubscriptionId '$(azure-subscription-id-cn)'
4449
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id-cn)'
4550
-ProvisionerApplicationSecret '$(aad-azure-sdk-test-client-secret-cn)'
51+
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
4652
-Environment 'AzureChinaCloud'
4753
-Force
4854
-Verbose
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
steps:
3+
# https://github.com/actions/virtual-environments/issues/798
4+
- script: sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
5+
displayName: Bypass local DNS server to workaround issue resolving cognitiveservices names
6+
condition: and(succeededOrFailed(), eq(variables['OSVmImage'], 'ubuntu-18.04'))
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Example Usage: ./copy-readmes-to-docs.ps1 -CodeRepo C:/repo/sdk-for-python -DocRepo C:/repo/azure-docs-sdk-python
2+
# run the link updating script before this to get links fixed to the release
3+
# Highly recommended that you use Powershell Core.
4+
# git reset --hard origin/smoke-test on the doc repo prior to running this
5+
6+
param (
7+
[String]$CodeRepo,
8+
[String]$DocRepo,
9+
[String]$TargetServices
10+
)
11+
12+
$PACKAGE_README_REGEX = ".*[\/\\]sdk[\\\/][^\/\\]+[\\\/][^\/\\]+[\/\\]README\.md"
13+
14+
Write-Host "repo is $CodeRepo"
15+
16+
$date = Get-Date -Format "MM/dd/yyyy"
17+
18+
if ($CodeRepo -Match "net")
19+
{
20+
$lang = ".NET"
21+
$TARGET_FOLDER = Join-Path -Path $DocRepo -ChildPath "api/overview/azure"
22+
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/dotnet-packages.csv"
23+
}
24+
if ($CodeRepo -Match "python"){
25+
$lang = "Python"
26+
$TARGET_FOLDER = Join-Path -Path $DocRepo -ChildPath "docs-ref-services"
27+
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/python-packages.csv"
28+
}
29+
if ($CodeRepo -Match "java"){
30+
$lang = "Java"
31+
$TARGET_FOLDER = Join-Path -Path $DocRepo -ChildPath "docs-ref-services"
32+
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/java-packages.csv"
33+
}
34+
if ($CodeRepo -Match "js"){
35+
$lang = "JavaScript"
36+
$TARGET_FOLDER = Join-Path -Path $DocRepo -ChildPath "docs-ref-services"
37+
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/js-packages.csv"
38+
}
39+
40+
41+
42+
$metadataResponse = Invoke-WebRequest -Uri $metadataUri | ConvertFrom-Csv
43+
44+
if ([string]::IsNullOrWhiteSpace($TargetServices))
45+
{
46+
$selectedServices = $metadataResponse | ForEach-Object -Process {$_.RepoPath} | Get-Unique
47+
}
48+
else {
49+
$selectedServices = $TargetServices -Split "," | % { return $_.Trim() }
50+
}
51+
52+
53+
foreach($service in $selectedServices){
54+
$readmePath = Join-Path -Path $CodeRepo -ChildPath "sdk/$service"
55+
Write-Host "Examining: $readmePath"
56+
57+
$libraries = $metadataResponse | Where-Object { $_.RepoPath -eq $service }
58+
59+
foreach($library in $libraries){
60+
61+
$package = $library.Package
62+
$version = If ([string]::IsNullOrWhiteSpace($library.VersionGA)) {$library.VersionPreview} Else {$library.VersionGA}
63+
64+
$file = Join-Path -Path $readmePath -ChildPath "/$package/README.md" | Get-Item
65+
Write-Host "`tOutputting $($file.FullName)"
66+
67+
$fileContent = Get-Content $file
68+
69+
$fileContent = $fileContent -Join "`n"
70+
71+
$fileMatch = (Select-String -InputObject $fileContent -Pattern 'Azure .+? (client|plugin|shared) library for (JavaScript|Java|Python|\.NET)').Matches[0]
72+
73+
$header = "---`r`ntitle: $fileMatch`r`nkeywords: Azure, $lang, SDK, API, $service, $package`r`nauthor: maggiepint`r`nms.author: magpint`r`nms.date: $date`r`nms.topic: article`r`nms.prod: azure`r`nms.technology: azure`r`nms.devlang: $lang`r`nms.service: $service`r`n---`r`n"
74+
75+
$fileContent = $fileContent -replace $fileMatch, "$fileMatch - Version $version `r`n"
76+
77+
$fileContent = "$header $fileContent"
78+
79+
$readmeName = "$($file.Directory.Name.Replace('azure-','').Replace('Azure.', '').ToLower())-readme.md"
80+
81+
$readmeOutputLocation = Join-Path $TARGET_FOLDER -ChildPath $readmeName
82+
83+
Set-Content -Path $readmeOutputLocation -Value $fileContent
84+
}
85+
}

0 commit comments

Comments
 (0)