Skip to content

Commit a5c8aef

Browse files
authored
Merge pull request #4 from trallard/dev
Release 1.0.3
2 parents 83c0d0c + 49b1237 commit a5c8aef

6 files changed

Lines changed: 343 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
# Change Log
88
All notable changes to the "pitaya-smoothie" extension will be documented in this file.
99

10+
## RELEASE: 1.0.3
11+
12+
![FIX](https://img.shields.io/badge/-FIX-gray.svg?colorB=FC427B)
13+
14+
> ✨ Changed comments foreground to increase the contrast ratio [`afe1c39`](https://github.com/trallard/pitaya_smoothie/commit/afe1c39)
15+
16+
![NEW](https://img.shields.io/badge/-NEW-gray.svg?colorB=12CBC4)
17+
18+
> 📦 Add support for Restructuredtext [33bd1bd](https://github.com/trallard/pitaya_smoothie/commit/33bd1bd) <br>
19+
> 📦 Add active tab border colour [e42baea](https://github.com/trallard/pitaya_smoothie/commit/e42baea)
20+
1021
## RELEASE: 1.0.2
1122

1223
![FIX](https://img.shields.io/badge/-FIX-gray.svg?colorB=FC427B)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
![License](https://img.shields.io/badge/License-BSD%203--Clause-gray.svg?colorA=2D2A56&colorB=7A76C2&style=flat.svg)
1212
[![Version](https://vsmarketplacebadge.apphb.com/version/trallard.pitaya-smoothie.svg?subject=Pitaya%20Smoothie&colorA=2D2A56&colorB=7A76C2&style=flat.svg)](https://marketplace.visualstudio.com/items?itemName=trallard.pitaya-smoothie)
13-
![GH actions](https://github.com/trallard/pitaya_smoothie/workflows/Publish%20release/badge.svg)
13+
1414

1515
<table width='100%' align="center">
1616
<tr>
@@ -54,7 +54,7 @@ I also made decisions to allow for meaningful contrast for reading comprehension
5454
| -------------- | -------------------------------------------------------------------- |
5555
| Background | ![#181036](https://placehold.it/15/181036/000000?text=%20) `#181036` |
5656
| Foreground | ![#fefeff](https://placehold.it/15/fefeff/000000?text=%20) `#fefeff` |
57-
| Comment | ![#5C588A](https://placehold.it/15/5C588A/000000?text=%20) `#5C588A` |
57+
| Comment | ![#7E7AAA](https://placehold.it/15/7E7AAA/000000?text=%20) `#5C588A` |
5858
| Keyword | ![#f62196](https://placehold.it/15/f62196/000000?text=%20) `#f62196` |
5959
| String | ![#7998F2](https://placehold.it/15/7998F2/000000?text=%20) `#7998F2` |
6060
| Number | ![#f3907e](https://placehold.it/15/f3907e/000000?text=%20) `#f3907e` |

demo-scripts/rst.rst

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
|pipe| Adding Blob storage bindings
2+
====================================
3+
4+
You should now have a working function that collects data from the StackExchange API.
5+
6+
In this section, we will:
7+
8+
- Complete the function to store the data in AzureBlob storage
9+
- Create a second function that identifies the addition of a file to Azure Blob storage and triggers a second function
10+
- Create a database to store our cleaned data and modify the function to store the database
11+
12+
.. tip:: The repository containing all the scripts and solutions to this tutorial can be found at `<https://github.com/trallard/pycon2020-azure-functions>`_.
13+
14+
👉🏼 The code for this section is located in `<https://github.com/trallard/pycon2020-azure-functions/tree/master/solutions/02-timer-function-Blob-binding>`_
15+
16+
17+
|light| Triggers and bindings
18+
--------------------------------
19+
20+
- **Triggers**: these cause a function to run. They can be an HTTP request, a queue message or an event grid. Each function **must** have one trigger.
21+
22+
- **Binding**: is a connection between a function and another resource or function. They can be *input bindings, output bindings* or both. These are optional, and a function can have one or more bindings.
23+
24+
1. Create Azure Blob Storage
25+
******************************************
26+
27+
We already created a Storage Account in the :ref:`deployfn` section. The next step is to create a Blob Storage container so we can start saving the data collected through your function.
28+
29+
#. Head over to |azureportal| and click on **Storage accounts** on the left sidebar and then on your function storage account.
30+
31+
.. image:: _static/images/snaps/storagedashboard.png
32+
:align: center
33+
:alt: Storager dashboard
34+
35+
#. Click on either of the **Containers** section (see image).
36+
37+
.. image:: _static/images/snaps/containers.png
38+
:align: center
39+
:alt: Containers screenshot
40+
41+
#. Click on **+ Container** at the top of the bar and provide a name for your Blob container.
42+
43+
#. Without leaving your dashboard, click on **Access keys** on the sidebar menu and copy the Connection string.
44+
45+
.. image:: _static/images/snaps/access.png
46+
:align: center
47+
:alt: Storage dashboard access
48+
49+
.. _attachblob:
50+
51+
2. Attach Blob binding
52+
******************************************
53+
54+
Now that you created the Blob container, you need to add the binding to your function.
55+
56+
1. Back in VS Code click on the **Azure** extension on the sidebar and then right-click on your function name > **Add binding**.
57+
2. Since we want to store the outputs in the container, we need to select the **OUT** direction followed by **Azure Blob Storage**.
58+
3. Assign a name for the binding a path for the blob:
59+
60+
.. code-block::
61+
62+
functionblob/{DateTime}.csv
63+
64+
Notice that I am using the name of the container I created before and the binding expression ``DateTime`` which resolves to ``DateTime.UtcNow``. The following blob path in a ``function.json`` file creates a blob with a name like ``2020-04-16T17-59-55Z.txt``.
65+
66+
4. Select **AzureWebJobsStorage** for your local settings.
67+
68+
Once completed, your ``function.json`` file should look like this:
69+
70+
.. literalinclude:: ../solutions/02-timer-function-Blob-binding/timer-function/function.json
71+
:language: json
72+
:caption: function.json
73+
74+
75+
5. Add the **Storage access key** that you copied before to your ``local.settings.json``. If you added your storage account through the Azure functions extensions, this should already be populated.
76+
77+
.. code-block::
78+
:caption: local.settings.json
79+
:emphasize-lines: 4
80+
81+
{
82+
"IsEncrypted": false,
83+
"Values": {
84+
"AzureWebJobsStorage": <Your key>,
85+
"FUNCTIONS_WORKER_RUNTIME": "python",
86+
"AzureWebJobs.timer-function.Disabled": "false"
87+
}
88+
}
89+
90+
.. _blobfunction:
91+
92+
3. Update your function
93+
*****************************
94+
95+
We now need to update the function so that:
96+
97+
- Save the collected API items in a CSV file
98+
- Store the file in the Blob container
99+
100+
Updating the `main_function.py` file:
101+
102+
.. literalinclude:: ../solutions/02-timer-function-Blob-binding/timer-function/main_function.py
103+
:language: python
104+
:caption: main_function.py
105+
:emphasize-lines: 7, 33-53, 61-63, 87-93
106+
107+
Notice these lines in the above code:
108+
109+
.. code-block:: python
110+
111+
112+
def main(
113+
mytimer: func.TimerRequest,
114+
outputBlob: func.Out[bytes],
115+
context: func.Context
116+
) -> None:
117+
118+
The ``outputBlob: func.Out[bytes]`` specifies the binding we just created and ``context: func.Context`` allows the function to get the context from the `host.json` file.
119+
120+
And also the script to access the StackExchange API:
121+
122+
.. literalinclude:: ../solutions/02-timer-function-Blob-binding/timer-function/utils/stack.py
123+
:language: python
124+
:caption: utils/stack.py
125+
126+
If you want, you can follow the steps in section :ref:`localdebug` to run and debug your function locally.
127+
128+
Otherwise, you can deploy and execute your function as we did in section :ref:`deployandrun` (except for the variables setting section as your storage details should be there already).
129+
130+
131+
.. tip:: When deploying your function, you can click on the pop-up window **output window** link to track the deployment status/progress.
132+
133+
.. image:: _static/images/snaps/explore.png
134+
:align: center
135+
:alt: Explore deploy
136+
137+
After running your function you can head over to **Storage accounts > <your account> > Containers** and click on your function Blob container.
138+
139+
If all runs smoothly, you should be able to see the created file.
140+
141+
.. image:: _static/images/snaps/blob_file.png
142+
:align: center
143+
:alt: Blob file
144+
145+
146+
147+
|floppy| Additional resources and docs
148+
---------------------------------------
149+
150+
- `ARM template for Blob Storage container <https://github.com/trallard/pycon2020-azure-functions/tree/master/storage-blob-container>`_
151+
- `Azure functions triggers and bindings <https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings?WT.mc_id=pycon_tutorial-github-taallard>`_
152+
- `Azure functions supported bindings <https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#supported-bindings?WT.mc_id=pycon_tutorial-github-taallard>`_
153+
- `Azure Storage documentation <http://azure.microsoft.com/documentation/articles/storage-create-storage-account?WT.mc_id=pycon_tutorial-github-taallard>`_
154+
- `Binding expressions docs <https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-expressions-patterns?WT.mc_id=pycon_tutorial-github-taallard>`_
155+
- `Azure function reference output <https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python#outputs?WT.mc_id=pycon_tutorial-github-taallard>`_
156+
- `Python type hints cheatsheet <https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html>`_

themes/Pitaya smoothie-color-theme-noitalic.json

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"tab.inactiveBackground": "#1f1445",
109109
"tab.activeForeground": "#9491ce",
110110
"tab.inactiveForeground": "#484f7d",
111+
"tab.activeBorder": "#31E6E6",
111112
// Title bar
112113
"titleBar.activeBackground": "#1E1E3F",
113114
"titleBar.activeForeground": "#789EF8",
@@ -538,7 +539,7 @@
538539
"name": "Double-Slashed Comment",
539540
"scope": "comment.line.double-slash",
540541
"settings": {
541-
"foreground": "#5C588A"
542+
"foreground": "#7E7AAA"
542543
}
543544
},
544545
{
@@ -1034,7 +1035,7 @@
10341035
"comment.block.html"
10351036
],
10361037
"settings": {
1037-
"foreground": "#5C588A"
1038+
"foreground": "#7E7AAA"
10381039
}
10391040
},
10401041
// JSON
@@ -1130,7 +1131,7 @@
11301131
"meta.diff.header.from-file"
11311132
],
11321133
"settings": {
1133-
"foreground": "#5C588A"
1134+
"foreground": "#7E7AAA"
11341135
}
11351136
},
11361137
{
@@ -1342,7 +1343,7 @@
13421343
"punctuation.definition.comment"
13431344
],
13441345
"settings": {
1345-
"foreground": "#5C588A"
1346+
"foreground": "#7E7AAA"
13461347
}
13471348
},
13481349
{
@@ -1513,6 +1514,88 @@
15131514
"foreground": "#C4A2F5"
15141515
}
15151516
},
1517+
// RST
1518+
{
1519+
"name": "RST - punctuation",
1520+
"scope": [
1521+
"punctuation.definition.heading.restructuredtext",
1522+
"markup.heading.restructuredtxt",
1523+
],
1524+
"settings": {
1525+
"foreground": "#82b1ff",
1526+
}
1527+
},
1528+
{
1529+
"name": "RST - directives",
1530+
"scope": [
1531+
"support.directive.restructuredtext"
1532+
],
1533+
"settings": {
1534+
"foreground": "#7ef3ca",
1535+
}
1536+
},
1537+
{
1538+
"name": "RST - substitutions",
1539+
"scope": [
1540+
"markup.underline.substitution.restructuredtext",
1541+
"markup.underline.link",
1542+
"punctuation.definition.substitution.restructuredtext"
1543+
],
1544+
"settings": {
1545+
"foreground": "#66E9EC",
1546+
}
1547+
},
1548+
{
1549+
"name": "RST - references",
1550+
"scope": [
1551+
"entity.name"
1552+
],
1553+
"settings": {
1554+
"foreground": "#A599E9",
1555+
}
1556+
},
1557+
{
1558+
"name": "RST - lists",
1559+
"scope": [
1560+
"markup.list.restructuredtext",
1561+
"beginning.punctuation.definition.list.restructuredtext",
1562+
"punctuation.definition.list.begin.restructuredtext",
1563+
"markup.list.unnumbered.restructuredtext",
1564+
"markup.list.numbered.restructuredtext",
1565+
],
1566+
"settings": {
1567+
"foreground": "#82b1ff",
1568+
}
1569+
},
1570+
{
1571+
"name": "RST - bold",
1572+
"scope": [
1573+
"markup.bold.restructuredtext"
1574+
],
1575+
"settings": {
1576+
"foreground": "#F3CA7E",
1577+
"fontStyle": "bold"
1578+
}
1579+
},
1580+
{
1581+
"name": "RST -inline code",
1582+
"scope": [
1583+
"markup.inline.raw.string.restructuredtext",
1584+
"punctuation.definition.raw.restructuredtext",
1585+
"markup.raw.restructuredtext"
1586+
],
1587+
"settings": {
1588+
"foreground": "#A599E9",
1589+
}
1590+
},
1591+
{
1592+
"name": "RST - Color for Emphasis Italic",
1593+
"scope": "markup.italic.restructuredtext",
1594+
"settings": {
1595+
"fontStyle": "italic",
1596+
"foreground": "#b07afc"
1597+
}
1598+
},
15161599
// SASS
15171600
{
15181601
"name": "SCSS Variable",

0 commit comments

Comments
 (0)